我已经在我的Linux
系统(ubuntu 12.04
)上正确地启动和运行了python 2.7.3
和ipython 1.2
,但我正在尝试安装课程作业所需的matplotlab的更新版本。
在终端中运行此代码行后
user$ sudo easy_install -U distribute
user$ export PYTHONHOME=/usr/lib/python2.7/
现在,每次我尝试运行python
或ipython
时,都会收到错误消息
ImportError: no module named site
如何反转/修复此问题??我太迷茫了。我查看了其他类似的问题,但没有其他人使用Linux
,我不确定该怎么办。
发布于 2016-03-29 16:39:46
尝试取消设置您的python路径...
在Linux/Mac中,您可以使用以下命令:
unset PYTHONPATH
unset PYTHONHOME
发布于 2015-04-03 01:33:32
你可以通过unset PYTHONHOME
来使用系统默认值,或者使用export PYTHONHOME=/usr
来指定前缀,Python会在前缀后面附加'/lib/python2.7‘(或者任何版本)来定位它的库。
如果使用export PYTHONHOME=/usr/lib/python2.7
,Python将在不存在的文件夹/usr/lib/python2.7/lib/python2.7
中查找库。
如果您使用export PYTHONHOME=
,您将告诉Python在当前工作目录中查找lib
:
jcomeau@aspire:~$ PYTHONHOME= strace -estat64 /usr/bin/python
stat64("lib/python2.7/", 0xff870ee0) = -1 ENOENT (No such file or directory)
stat64("lib/python2.7", 0xff870ee0) = -1 ENOENT (No such file or directory)
stat64("lib", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0
stat64("lib/python2.7/", 0xff873efc) = -1 ENOENT (No such file or directory)
stat64("lib/python2.7/plat-i386-linux-gnu", 0xff870ee0) = -1 ENOENT (No such file or directory)
stat64("lib/python2.7", 0xff870ee0) = -1 ENOENT (No such file or directory)
stat64("lib", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0
stat64("lib/python2.7/plat-i386-linux-gnu", 0xff873efc) = -1 ENOENT (No such file or directory)
stat64("lib/python2.7/lib-tk", 0xff870ee0) = -1 ENOENT (No such file or directory)
stat64("lib/python2.7", 0xff870ee0) = -1 ENOENT (No such file or directory)
stat64("lib", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0
stat64("lib/python2.7/lib-tk", 0xff873efc) = -1 ENOENT (No such file or directory)
stat64("lib/python2.7/lib-old", 0xff870ee0) = -1 ENOENT (No such file or directory)
stat64("lib/python2.7", 0xff870ee0) = -1 ENOENT (No such file or directory)
stat64("lib", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0
stat64("lib/python2.7/lib-old", 0xff873efc) = -1 ENOENT (No such file or directory)
stat64("lib/python2.7/lib-dynload", 0xff870ee0) = -1 ENOENT (No such file or directory)
stat64("lib/python2.7", 0xff870ee0) = -1 ENOENT (No such file or directory)
stat64("lib", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0
stat64("lib/python2.7/lib-dynload", 0xff873efc) = -1 ENOENT (No such file or directory)
ImportError: No module named site
https://stackoverflow.com/questions/21874407
复制相似问题