Reputation: 271
I am suddenly getting the following error in PyCharm whenever I try to debug my code. This seems to be happening only when I try to debug a specific project and the error doesn't seem to occur in other projects.
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 14, in <module>
from pydevd_breakpoints import * #@UnusedWildImport
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd_breakpoints.py", line 15, in <module>
from pydevd_comm import GetGlobalDebugger
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd_comm.py", line 74, in <module>
import pydevconsole
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevconsole.py", line 8, in <module>
from code import compile_command
ImportError: cannot import name compile_command
I searched around and found this answer, but it didn't work for me since I have no additional code.py
in my project.
UPDATE:
I created a new project in PyCharm and moved the files the files to the new project and was able to debug..
Upvotes: 25
Views: 13821
Reputation: 728
We added env setting DISABLE_DEBUGPY, wo we do not import debugpy when using PyCharm.
Upvotes: 0
Reputation: 21
I removed the empty init.py file, from my directory and reran the debugger in PyCharm. It worked for me.
Upvotes: 1
Reputation: 393
As said before, this was caused by a module named code
(i.e. a directory named code
with a __init__.py
in it). I renamed it to src
and it corrected the bug.
Upvotes: 17
Reputation: 1429
A directory called 'code' that had somehow acquired an empty __init__.py
file caused this for me. I suppose that's technically a module!
Edit: This happened again. Pycharm itself is creating these __init__.py
files. I haven't found out what's triggering it yet though.
Upvotes: 21
Reputation: 3165
I had same question, because i have a unrelated sub directory where contains file code.py, actually i did not use it as code, i just use it as data file to do some word counting test.
Finally, i move the sub directory out of the project.
...
test_data_file_dir
...
code.py
...
...
It seems pyCharm will load all .py files of the project no matter of how i use them.
Upvotes: 4