Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module 'trace' has no attribute 'modname' while trying to debug in PyCharm (Python 3.6)

I have Python 3.6rc1 installed from the official "pkg" bundle for Mac OS. Now, every time I'm using a "debug" run configuration in PyCharm (does not depend on a particular script), I'm getting a huge stack trace with the following error messages (thrown multiple times in a row):

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_signature.py", line 88, in create_signature
    filename, modulename, funcname = self.file_module_function_of(frame)
  File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_signature.py", line 102, in file_module_function_of
    modulename = trace.modname(filename)
AttributeError: module 'trace' has no attribute 'modname'

Using the currently latest PyCharm 2016.3. Note that I can debug using Python 2.7 or 3.5 using the same PyCharm instance without any problems.

Has anyone experienced anything like this? Is there a workaround?


Posting on SO since I'm not completely sure this is actually a bug or I've misconfigured something; plus, I know that PyCharm team checks the pycharm tag here; and, it would be easier for others to find this topic here as opposed to on the PyCharm's bug tracker.

like image 270
alecxe Avatar asked Dec 12 '16 20:12

alecxe


People also ask

Why does PyCharm debugger not work?

Faced the same issue and even tried different PyCharm versions without success. In the end the reason for debugging console not working was that somewhere in the repo sys. out and sys. stderr were being overwritten.

How do I trace a Python program in PyCharm?

Press the Autoscroll to Trace toggle button on the toolbar. After that, on clicking a node in the Events pane, PyCharm shows its call stack in the Event Stack pane aqnd opens the corresponding trace file in the editor.

How do you debug a function in PyCharm?

From the main menu, select Run | Debugging Actions | Force Run to Cursor or press Ctrl+Alt+F9 .


1 Answers

There is actually a bug in the PyCharm's PyDev.Debugger, it uses the trace.modname which does not exist since Python 3.2:

def file_module_function_of(self, frame): #this code is take from trace module and fixed to work with new-style classes
    code = frame.f_code
    filename = code.co_filename
    if filename:
        modulename = trace.modname(filename)  # < HERE
    else:
        modulename = None
    # ...

Now, this particular code would only be executed if the debugger is started with the --save-signatures command-line option which is enabled by the "Collect run-time types information for code insight" Python debugger setting:

enter image description here

Turn the setting off and the error would go away.

like image 122
alecxe Avatar answered Sep 28 '22 07:09

alecxe