Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm debugger fails with AttributeError

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?

like image 312
nicks Avatar asked May 12 '16 08:05

nicks


1 Answers

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.

like image 74
smerlin Avatar answered Sep 19 '22 14:09

smerlin