首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Python/IPython ImportError:没有命名为site的模块

Python/IPython ImportError:没有命名为site的模块
EN

Stack Overflow用户
提问于 2014-02-19 16:01:43
回答 2查看 82.3K关注 0票数 25

我已经在我的Linux系统(ubuntu 12.04)上正确地启动和运行了python 2.7.3ipython 1.2,但我正在尝试安装课程作业所需的matplotlab的更新版本。

在终端中运行此代码行后

代码语言:javascript
复制
user$ sudo easy_install -U distribute
user$ export PYTHONHOME=/usr/lib/python2.7/

现在,每次我尝试运行pythonipython时,都会收到错误消息

代码语言:javascript
复制
ImportError: no module named site

如何反转/修复此问题??我太迷茫了。我查看了其他类似的问题,但没有其他人使用Linux,我不确定该怎么办。

EN

回答 2

Stack Overflow用户

发布于 2016-03-29 16:39:46

尝试取消设置您的python路径...

在Linux/Mac中,您可以使用以下命令:

代码语言:javascript
复制
unset PYTHONPATH
unset PYTHONHOME
票数 25
EN

Stack Overflow用户

发布于 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

代码语言:javascript
复制
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
票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21874407

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档