损坏的 Python ImportError:没有名为 _sysconfigdata_nd 的模块

损坏的 Python ImportError:没有名为 _sysconfigdata_nd 的模块

安装后,我使用 conda 安装了 python 3.5,然后删除 conda。

删除之前,我可以访问 pip 等。在终端上,任何 python 命令都会产生这样的结果,如下面的屏幕截图所示:

jjplack@jjplack:~$ pip --version
Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 554, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 536, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 272, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 247, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 237, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 587, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 533, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 417, in _init_posix
    from _sysconfigdata import build_time_vars
  File "/usr/lib/python2.7/_sysconfigdata.py", line 6, in <module>
    from _sysconfigdata_nd import *
ImportError: No module named _sysconfigdata_nd

因此,为了尝试修复,我将 bash 改回 python 2,但错误仍然出现。为什么会发生这种情况以及如何修复它?

这是 bash_config:

export PYTHONHOME=/usr/bin
export PYTHONPATH=/usr/lib/python2.7
export PATH=$PYTHONPATH:$PATH

答案1

无需修复,只需在终端上输入:ln -fs /usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata.py /usr/lib/python2.7/

相关内容