Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to debug in PyCharm because of an ImportError in pydevconsole.py

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..

like image 387
Elias H Avatar asked Mar 20 '15 17:03

Elias H


People also ask

How do I enable Debug mode in PyCharm?

Just right-click any line in the editor and select the Debug <filename> command from the context menu. After the program has been suspended, use the debugger to get the information about the state of the program and how it changes during running.

How do I Debug a script in PyCharm?

Start debuggingOpen the HTML file that references the JavaScript to debug or select the HTML file in the Project tool window. From the context menu of the editor or the selection, choose Debug <HTML_file_name>. PyCharm generates a debug configuration and starts a debugging session through it.

What does the lightning bolt mean in PyCharm?

Another breakpoint appeared as well: by default PyCharm will halt for any exception that wasn't caught in your code, and it'll show an icon of a breakpoint with a lightning bolt. The debugger also shows the error message.

How do I use Pydev debugger?

Use Ctrl+F10 to open the context-menu and then select Add Breakpoint; Right-click the left bar to open the context-menu and then select Add Breakpoint; Use Ctrl+Shift+B to toggle the breakpoint in the line (if it doesn't work, go to the customize perspective and enable Breakpoints in Action Set Availability.


1 Answers

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.

like image 141
Melanie Avatar answered Sep 19 '22 08:09

Melanie