gpt4 book ai didi

python - 运行 Python 2.7 会报错

转载 作者:行者123 更新时间:2023-11-28 21:49:47 25 4
gpt4 key购买 nike

File "/usr/lib/python2.7/site.py", line 563, in <module>
main()

这是我在使用 Python 运行 ubuntu 14.04 时收到的错误。

Python 3 工作正常,运行脚本或使用 Python 解释器时会出现此错误。

完整跟踪:

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 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 578, in get_config_var
return get_config_vars().get(name)
File "/usr/lib/python2.7/sysconfig.py", line 524, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/usr/lib/python2.7/sysconfig.py", line 408, 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

这个错误看起来像是路径错误,我最近也安装了 wxPython,但没有对路径进行任何更改。

编辑:

我重置了我的 Python 路径,但我现在遇到了不同的错误,希望这对调试来说是件好事。

新错误:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

最佳答案

安装anaconda后我遇到了同样的问题。当我尝试在 anaconda 环境中使用 python 控制台时,出现了这个错误。下面的代码解决了我的问题。

cd /usr/lib/python2.7
sudo ln -s plat-x86_64-linux-gnu/_sysconfigdata_nd.py .

关于python - 运行 Python 2.7 会报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33005928/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com