NameError: name N_TOKENS is not defined

2024/10/15 21:14:45

I am new on Python and just got around to install PyCharm for Windows. Downloaded some sample code from Skype for testing their SkypeKit API. But... As soon as I hit the debug button, I get this: (I have Python 2.7 and Django 1.4 installed)

Traceback (most recent call last):File "C:\Program Files (x86)\JetBrains\PyCharm 2.0.2\helpers\pydev\pydevd.py", line 2, in <module>from django_debug import DjangoLineBreakpointFile "C:\Program Files (x86)\JetBrains\PyCharm 2.0.2\helpers\pydev\django_debug.py", line 1, in <module>import inspectFile "C:\Program Files (x86)\Python27\lib\inspect.py", line 39, in <module>import tokenizeFile "C:\Program Files (x86)\Python27\lib\tokenize.py", line 38, in <module>COMMENT = N_TOKENS
NameError: name 'N_TOKENS' is not definedProcess finished with exit code 1

What does this mean and what can I do to fix it?

Answer

The tokenize.py module is probably loading the wrong token.py module. See error importing numpy. Solution 1) rename the new token.py (token2.py) and update references to it in tokenize.py etc. Solution 2) if the new token.py is in a python package you can disambiguate the import statement:

import CorrectPythonPackage.token as token2#or from CorrectPythonPackage.token import *

Where CorrectPythonPackage is the folder name containing the token.py file.

https://en.xdnf.cn/q/69239.html

Related Q&A

Moving Spark DataFrame from Python to Scala whithn Zeppelin

I created a spark DataFrame in a Python paragraph in Zeppelin.sqlCtx = SQLContext(sc) spDf = sqlCtx.createDataFrame(df)and df is a pandas dataframeprint(type(df)) <class pandas.core.frame.DataFrame&…

How do I efficiently do a bulk insert-or-update with SQLAlchemy?

Im using SQLAlchemy with a Postgres backend to do a bulk insert-or-update. To try to improve performance, Im attempting to commit only once every thousand rows or so:trans = engine.begin()for i, rec in…

How to pass variables from javascript to python in Jupyter?

As I understand it, I should be able to print the variable foo in the snippet below. from IPython.display import HTML HTML(<script type="text/javascript">IPython.notebook.kernel.execute…

SVR Model --Feature Scaling - Expected 2D array, got 1D array instead

I am trying to understand what is wrong with the code below. I know that the Y variable is 1D array and expected to be 2D array and need to reshape the structure but that code was working previously fi…

How to find the version of jupyter notebook from within the notebook

I wish to return the version of Jupyter Notebook from within a cell of a notebook. For example, to get the python version, I run: from platform import python_version python_version()or to get the panda…

Python logging - multiple modules

Im working on a small python project that has the following structure -project -- logs-- project__init.py__classA.pyclassB.pyutils.py-- main.pyIve set up the logging configuration in __init.py__ under …

Can you search backwards from an offset using a Python regular expression?

Given a string, and a character offset within that string, can I search backwards using a Python regular expression?The actual problem Im trying to solve is to get a matching phrase at a particular of…

Django AttributeError: Form object has no attribute _errors

Im overriding the init method in my form andthis is now returning an error TransactionForm object has no attribute _errors. I would expect this to work because Ive included super in my init, however pe…

Add new keys to a dictionary while incrementing existing values

I am processing a CSV file and counting the unique values of column 4. So far I have coded this three ways. One uses "if key in dictionary", the second traps the KeyError and the third uses &…

ImportError: cannot import name aiplatform from google.cloud (unknown location)

I was wondering where that error comes from. The package has to be installed additionally to google.cloud