这个 python2 错误是什么意思,我该怎么办?

这个 python2 错误是什么意思,我该怎么办?

每当我尝试使用与 python2(gnome-tweak-tool、bzr 等)相关的应用程序时,它都无法启动,并且当从命令行运行时,我收到此错误:

    [username@host ~]$ gnome-tweak-tool
Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 563, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 278, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 253, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 243, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 520, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 419, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 287, in _init_posix
    raise IOError(msg)
IOError: invalid Python installation: unable to open /usr/bin/lib/python2.7/config/Makefile (No such file or directory)

我已将其发布于阿库本图,但被告知它属于这里,因为我使用 Arch Linux。 python2 的输出:

    [username@host ~]$ python2
Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 563, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 278, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 253, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 243, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 520, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 419, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 287, in _init_posix
    raise IOError(msg)
IOError: invalid Python installation: unable to open /usr/bin/lib/python2.7/config/Makefile (No such file or directory)

答案1

可能你的Python安装搞砸了:/usr/bin/lib/python2.7/...没有意义,因为Python将其内容安装在/usr/lib/python2.7

尝试删除 python 包,然后重新安装。

答案2

在 Ubuntu 上,我能够让它工作

export PYTHONPATH=/usr/lib/pymodules/python2.7:/usr/lib/python2.7

export PYTHONHOME=/usr/lib/python2.7

sudo ln -s /usr/lib /usr/lib/python2.7/lib

sudo ln -s /usr /usr/lib/python2.7/local

sysconfig.py 中可能存在错误,它在另一个绝对路径之上附加绝对路径(忽略实际的系统路径和设置),而不是在绝对路径之上附加相对路径

相关内容