PyCharm调试器失败并出现AttributeError [英] PyCharm debugger fails with AttributeError

查看:128
本文介绍了PyCharm调试器失败并出现AttributeError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在PyCharm中调试Flask应用程序.该应用程序应在端口5000上运行: app.run(host ="10.1.0.17",port = 5000,debug = True).控制台输出为:

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

我正在使用Python 3.5.1.有什么问题吗?

I am using Python 3.5.1. What could be wrong?

推荐答案

pydev调试器使用与尝试调试的项目相同的Pythonpath.如果您有任何带有标准模块或软件包名称的模块或软件包,则pydev调试器可能会加载您的模块而不是标准模块.

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.

您的项目目录中可能有一个名为 queue 的模块,这会导致此问题,因为python标准库也包含具有该名称的模块.

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.

尝试重命名模块或更改PYTHONPATH

try renaming your module, or changing your PYTHONPATH

PyCharm可以选择不在 Run>中的PYTHONPATH中包含项目根目录/源根目录.编辑配置.尽管您可能需要修复项目中的某些 import 语句,但是如果您的任何 import 语句均依赖此设置,则这可能会解决您的问题.

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.

这篇关于PyCharm调试器失败并出现AttributeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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