[英]PyCharm debugger doesn't work
我刚刚下载了 PyCharm 社区版,每次尝试调试 PyCharm 中的任何 Python 程序时,我都会收到此错误:
C:\Python31\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community
Edition 2016.1\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 59207 --file C:/Users/Gal/PycharmProjects/untitled/test.py
pydev debugger: process 5388 is connecting
Connected to pydev debugger (build 145.260)
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1\helpers\pydev\pydevd.py", line 1530, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1\helpers\pydev\pydevd.py", line 937, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 11, in execfile
stream = tokenize.open(file) # @UndefinedVariable
AttributeError: 'module' object has no attribute 'open'
一个名为“_pydec_excecfile.py”的 python 文件打开:
#We must redefine it in Py3k if it's not already there
def execfile(file, glob=None, loc=None):
if glob is None:
import sys
glob = sys._getframe().f_back.f_globals
if loc is None:
loc = glob
# It seems that the best way is using tokenize.open(): http://code.activestate.com/lists/python-dev/131251/
import tokenize
stream = tokenize.open(file) # @UndefinedVariable
try:
contents = stream.read()
finally:
stream.close()
#execute the script (note: it's important to compile first to have the filename set in debug mode)
exec(compile(contents+"\n", file, 'exec'), glob, loc)
我该如何解决?
我在一个名为“tokenizer.py”的文件的项目中遇到过类似情况。 在尝试调试同一项目中的不同 Python 代码时(即使在不同的文件中),我收到以下错误 output:
Traceback (most recent call last):
File "C:\Programs\PyCharm\plugins\python-ce\helpers\pydev\pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Programs\PyCharm\plugins\python-ce\helpers\pydev\_pydev_imps \_pydev_execfile.py", line 11, in execfile
stream = tokenize.open(file) # @UndefinedVariable
AttributeError: module 'tokenize' has no attribute 'open'
我可以运行代码,但不能调试它。 然后我在链接上找到了一个讨论,认为代码中的一个模块隐藏了调试器所需的一些顶级 package。 我重命名了“tokenizer”模块,并且可以再次进行调试。 这似乎是秘诀:尝试重命名错误 output 中提到的模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.