jnmcclai
jnmcclai

Reputation: 69

PyCharm Debugger - ImportError: cannot import name getargspec

When I run the PyCharm debugger to debug python code I get the below error message. The tests themselves run fine from PyCharm and outside of PyCharm. I use a virtualenv and have gotten this to work many times before, but this is with a newer setup with a differnet version of PyCharm, Ubuntu, and Python

Version information:

Python 2.7.17 PyCharm 2019.3.1 (Community Edition) Build #PC-193.5662.61, built on December 18, 2019 Runtime version: 11.0.5+10-b520.17 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 5.3.0-24-generic GC: ParNew, ConcurrentMarkSweep Memory: 725M Cores: 8 Registry: Non-Bundled Plugins:

No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 19.10 Release: 19.10 Codename: eoan (venv) jnmcclai@jnmccl

/home/jnmcclai/workspace/adtn_1u_olt/venv/bin/python /snap/pycharm-community/172/plugins/python-ce/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 45823 --file /snap/pycharm-community/172/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py --path /home/jnmcclai/workspace/adtn_1u_olt/test/test_basic_plugin.py
Traceback (most recent call last):
  File "/snap/pycharm-community/172/plugins/python-ce/helpers/pydev/pydevd.py", line 37, in <module>
    from _pydevd_bundle.pydevd_comm import CMD_SET_BREAK, CMD_SET_NEXT_STATEMENT, CMD_STEP_INTO, CMD_STEP_OVER, \
  File "/snap/pycharm-community/172/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 91, in <module>
    from _pydevd_bundle import pydevd_console_integration
  File "/snap/pycharm-community/172/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_console_integration.py", line 14, in <module>
    from _pydev_bundle.pydev_code_executor import BaseCodeExecutor
  File "/snap/pycharm-community/172/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_code_executor.py", line 4, in <module>
    from _pydev_bundle._pydev_calltip_util import get_description
  File "/snap/pycharm-community/172/plugins/python-ce/helpers/pydev/_pydev_bundle/_pydev_calltip_util.py", line 20, in <module>
    from _pydev_bundle._pydev_imports_tipper import signature_from_docstring
  File "/snap/pycharm-community/172/plugins/python-ce/helpers/pydev/_pydev_bundle/_pydev_imports_tipper.py", line 9, in <module>
    from inspect import getargspec as _originalgetargspec
ImportError: cannot import name getargspec

Process finished with exit code 1

Empty suite

Empty suite

Upvotes: 1

Views: 2866

Answers (1)

jnmcclai
jnmcclai

Reputation: 69

Okay, I was able to get around this...

I had to configure the working directory path in the PyCharm run/debug configuration. Once I did this, the getargspect error did not occur when using the debugger. Example run/debug configuration below.

enter image description here

Also, we have a pytest.ini file that adds options to run code coverage. This causes a conflict with PyCharm's debugger and results in the debugger not "breaking" on breakpoints as it should. So I have to remove this line from our pytest.ini file to have the debugger break on breakpoints.

addopts = --cov=mcp_general --cov-append --cov-report= --cov-config=.coveragerc
          --doctest-modules -vv --junit-xml .coverage-dir/junit-results.xml

Upvotes: 3

Related Questions