调试Pycharm'python_implementation'时出错

时间:2019-10-20 15:27:33

标签: python pycharm virtualenv python-3.6

我正在从虚拟环境中将PyCharm与Python 3.6一起使用,并且在调试(而不是在运行时)脚本时出现以下错误:

/home/developer/master/bin/python3 /snap/pycharm-community/155/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 34977 --file /home/developer/motionplanningthesishector/Planner/control/studywolf_control/controllers/ilqr_truck.py
Traceback (most recent call last):
  File "/snap/pycharm-community/155/helpers/pydev/pydevd.py", line 20, in <module>
    from _pydevd_bundle.pydevd_constants import IS_JYTH_LESS25, IS_PYCHARM, get_thread_id, get_current_thread_id, \
  File "/snap/pycharm-community/155/helpers/pydev/_pydevd_bundle/pydevd_constants.py", line 183, in <module>
    from _pydev_imps._pydev_saved_modules import thread
  File "/snap/pycharm-community/155/helpers/pydev/_pydev_imps/_pydev_saved_modules.py", line 22, in <module>
    import xmlrpc.server as _pydev_SimpleXMLRPCServer
  File "/usr/lib/python3.6/xmlrpc/server.py", line 115, in <module>
    import pydoc
  File "/usr/lib/python3.6/pydoc.py", line 67, in <module>
    import platform
  File "/usr/lib/python3.6/platform.py", line 116, in <module>
    import sys, os, re, subprocess
  File "/usr/lib/python3.6/subprocess.py", line 50, in <module>
    import signal
  File "/home/developer/motionplanningthesishector/Planner/control/studywolf_control/controllers/signal.py", line 18, in <module>
    import numpy as np
  File "/home/developer/master/lib/python3.6/site-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/home/developer/master/lib/python3.6/site-packages/numpy/core/__init__.py", line 100, in <module>
    from . import _internal
  File "/home/developer/master/lib/python3.6/site-packages/numpy/core/_internal.py", line 20, in <module>
    IS_PYPY = platform.python_implementation() == 'PyPy'
AttributeError: module 'platform' has no attribute 'python_implementation'

我的Python安装似乎是正确的,因为我可以调试过去创建的其他文件,但不能调试任何新创建的脚本。

1 个答案:

答案 0 :(得分:2)

我在回溯的这一部分看到一个问题:

  File "/usr/lib/python3.6/subprocess.py", line 50, in <module>
    import signal

模块subprocess imports signal。它必须是this one;在目录结构中,它必须为/usr/lib/python3.6/signal.py。但是它尝试

  File "/home/developer/motionplanningthesishector/Planner/control/studywolf_control/controllers/signal.py", line 18, in <module>

我怀疑问题出在错误的sys.path$PYTHONPATH上。