简体   繁体   English

无法使用pycharm调试flask应用程序

[英]Cannot debug flask app using pycharm

I am trying to debug my flask app but when I start my wsgi script as debug It won't connect. 我正在尝试调试我的烧瓶应用程序,但当我启动我的wsgi脚本作为调试它将无法连接。 My wsgi.py 我的wsgi.py

from flask_app import app as application

if __name__ == "__main__":
    application.run(host="0.0.0.0", port=5000)

and console message 和控制台消息

pydev debugger: process 13472 is connecting

Connected to pydev debugger (build 143.1919)
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
 * Restarting with stat
pydev debugger: process 15356 is connecting

Running it normally works like a charm. 正常运行就像魅力一样。 How can I get any errors messages as indication to what is wrong? 如何获取任何错误消息作为错误的指示?

EDIT: 编辑:

it seems that it doesn't open the port in 5000 because when I run netstat -a and wsgi is running in debug mode, I don't see 0.0.0.0:5000 listening or timewait state anywhere. 似乎它没有在5000中打开端口,因为当我运行netstat -a并且wsgi在调试模式下运行时,我看不到0.0.0.0:5000监听或时间状态在任何地方。 WHen run normally I can see 0.0.0.0:5000 listening 如果正常运行我可以看到0.0.0.0:5000听

Just had the same problem with flask 0.12.1 and PyCharm 2017.1.2. 与烧瓶0.12.1和PyCharm 2017.1.2有同样的问题。

In PyCharm I ticked the 在PyCharm我勾选了

File > Settings > Build, Execution, Deployment > Debugger > 'Can accept external connections'

box, then restarted the debugger and it is now connecting to the pydev debugger. 框,然后重新启动调试器,它现在连接到pydev调试器。

Note that I have since unticked the box again and restarted the debugger and it still connects, so not sure if that is actually a legit solution, but seemed to work for me. 请注意,我再次取消了该框并重新启动调试器并且它仍然连接,所以不确定这是否真的是一个合法的解决方案,但似乎对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM