PyCharm调试器-ImportError:无法导入名称getargspec

问题描述 投票:0回答:1

[当我运行PyCharm调试器调试python代码时,出现以下错误消息。这些测试本身在PyCharm和PyCharm外部均可正常运行。我使用virtualenv并使其多次运行,但这是在更新的设置中使用的PyCharm,Ubuntu和Python的不同网络版本

版本信息:

Python 2.7.17PyCharm 2019.3.1(社区版)版本号PC-193.5662.61,于2019年12月18日建立运行时版本:11.0.5 + 10-b520.17 amd64VM:JetBrains s.r.o的OpenJDK 64位服务器VMLinux 5.3.0-24-通用GC:ParNew,ConcurrentMarkSweep记忆体:725M核心数:8注册表:非捆绑插件:

没有可用的LSB模块。发行人ID:Ubuntu说明:Ubuntu 19.10发行:19.10代号: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
python debugging pycharm
1个回答
0
投票

好的,我能够解决这个问题...

我必须在PyCharm运行/调试配置中配置working directory路径。一旦这样做,使用调试器时就不会发生getargspect错误。下面的示例运行/调试配置。

enter image description here

此外,我们还有一个pytest.ini文件,该文件添加了用于运行代码覆盖率的选项。这会导致与PyCharm的调试器发生冲突,并导致调试器没有在断点上“中断”。因此,我必须从pytest.ini文件中删除此行,以使调试器在断点处中断。

addopts = --cov=mcp_general --cov-append --cov-report= --cov-config=.coveragerc
          --doctest-modules -vv --junit-xml .coverage-dir/junit-results.xml
© www.soinside.com 2019 - 2024. All rights reserved.