PyCharm debugger doesn't work

2019-04-12 13:24发布

I just downloaded PyCharm community edition and every time I try to debug any Python program in PyCharm, I get this error:

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'

and a python file named "_pydec_excecfile.py" opens:

#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)

How can I fix it?

0条回答
登录 后发表回答