pycharm cannot debug with ModuleNotFound error

Answered

I have a app.py which could be run normally. Somehow the app.py cannot be debugged but can run without any problem.

I have tried:

  • re-install the pycharm from scratch, and delete all the settings and config
  • delete all breakpoints

The pycharm version is community edition 2017.2.4. The OS is windows7 64bit. The error log is:

D:\Users\dongb4\AppData\Local\Programs\Python\Python36\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.4\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 56027 --file D:/project/auto-handle/app.py
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.4\helpers\pydev\pydevd.py", line 13, in <module>
from _pydevd_bundle.pydevd_constants import IS_JYTH_LESS25, IS_PY3K, IS_PY34_OR_GREATER, get_thread_id, dict_keys, dict_contains, \
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.4\helpers\pydev\_pydevd_bundle\pydevd_constants.py", line 147, in <module>
from _pydev_imps._pydev_saved_modules import thread
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.4\helpers\pydev\_pydev_imps\_pydev_saved_modules.py", line 21, in <module>
import xmlrpc.client as xmlrpclib
File "D:\Users\dongb4\AppData\Local\Programs\Python\Python36\lib\xmlrpc\client.py", line 136, in <module>
import http.client
File "D:\Users\dongb4\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 71, in <module>
import email.parser
ModuleNotFoundError: No module named 'email.parser'; 'email' is not a package

4 comments
Comment actions Permalink

Jesus. It just because there is a file named email.py which conflicted with the module email. There is no indication of this. I waste the whole day to figured out this!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

1
Comment actions Permalink

It's worth discussing whether PyCharm should warn you if you name a module with the same name as something from the standard library or something you installed as a package. Although the latter can be tricky, as some packages do dynamic monkeying around with package names.

Stated differently, what do you think PyCharm should have done to warn you about your Python mistake?

0
Comment actions Permalink

That's a bogus answer. When a program runs directly but doesn't run in the debugger, that's a mistake in the debugger.

0
Comment actions Permalink

>  It just because there is a file named email.py which conflicted with the module email. There is no indication of this.

Totally agree with you. It would be great if you could describe this in same details & submit at http://youtrack.jetbrains.com/issues/PY#newissue=yes

0

Please sign in to leave a comment.