PyCharm debugger fails with AttributeError

匿名 (未验证) 提交于 2019-12-03 01:22:02

问题:

I cannot debug a Flask application in PyCharm. The application should run on port 5000: app.run(host="10.1.0.17", port=5000, debug=True). The console output is:

C:\Python\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 145.597.11\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 10498 --file "D:/TGM/SMS/SMS/Back .v2/wsgi.py"  pydev debugger: process 4108 is connecting Could not connect to 127.0.0.1: 10499  Traceback (most recent call last):   File "C:\Program Files (x86)\JetBrains\PyCharm 145.597.11\helpers\pydev\pydevd.py", line 1523, in <module>     debugger.connect(host, port)   File "C:\Program Files (x86)\JetBrains\PyCharm 145.597.11\helpers\pydev\pydevd.py", line 317, in connect     self.initialize_network(s)   File "C:\Program Files (x86)\JetBrains\PyCharm 145.597.11\helpers\pydev\pydevd.py", line 304, in initialize_network     self.writer = WriterThread(sock)   File "C:\Program Files (x86)\JetBrains\PyCharm 145.597.11\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 392, in __init__     self.cmdQueue = _queue.Queue() AttributeError: module 'queue' has no attribute 'Queue'  Process finished with exit code -1 

I am using Python 3.5.1. What could be wrong?

回答1:

The pydev debugger uses the same Pythonpath as the project you are trying to debug. If you have any modules or packages with names of standard modules or packages, the pydev debugger might load your module instead of the standard module.

You probably have a module called queue in your projects directories, which causes this issue, since the python standard library also includes a module with that name.

try renaming your module, or changing your PYTHONPATH

PyCharm has the option to not include the projects root/source roots in the PYTHONPATH in Run > Edit Configurations. This could fix your problem, although you might need to fix some import statements in your project, if any of your import statements relied on this setting.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!