NameError: name 'N_TOKENS' 未定义 [英] NameError: name 'N_TOKENS' is not defined

查看:43
本文介绍了NameError: name 'N_TOKENS' 未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Python 新手,刚开始为 Windows 安装 PyCharm.从 Skype 下载了一些示例代码以测试他们的 SkypeKit API.但是...一旦我点击调试按钮,我就会得到这个:(我安装了 Python 2.7 和 Django 1.4)

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 DjangoLineBreakpoint
  File "C:\Program Files (x86)\JetBrains\PyCharm 2.0.2\helpers\pydev\django_debug.py", line 1, in <module>
    import inspect
  File "C:\Program Files (x86)\Python27\lib\inspect.py", line 39, in <module>
    import tokenize
  File "C:\Program Files (x86)\Python27\lib\tokenize.py", line 38, in <module>
    COMMENT = N_TOKENS
NameError: name 'N_TOKENS' is not defined

Process finished with exit code 1

这是什么意思,我可以做些什么来解决它?

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

推荐答案

tokenize.py 模块可能加载了错误的 token.py 模块.请参阅导入 numpy 时出错.解决方案 1) 重命名新的 token.py (token2.py) 并在 tokenize.py 等中更新对它的引用. 解决方案 2) 如果新的 token.py 在 python 包中,您可以消除导入语句的歧义:

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 *

其中 CorrectPythonPackage 是包含 token.py 文件的文件夹名称.

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

这篇关于NameError: name 'N_TOKENS' 未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆