简体   繁体   English

我的新virtualenv获取ImportError:没有名为bz2的模块,但系统python可以导入

[英]My new virtualenv gets ImportError: No module named bz2 but system python can import

My virtualenv doesn't have the bz2 lib for whatever reason. 无论出于何种原因,我的virtualenv都没有bz2 lib。 I know I have bz2 becuase the system python can import it, how come my newly created virtualenv doesn't get it? 我知道我有bz2因为系统python可以导入它,为什么我新创建的virtualenv不能得到它?

$ mkvirtualenv sentry
$ python -c "import bz2"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named bz2
$ deactivate
$ python -c "import bz2"

I also tried to recompile python into the virtualenv directory, but it didn't seem to work. 我也尝试将python重新编译到virtualenv目录中,但它似乎没有用。

If you can actually import bz2 try to explicitly create a new virtualenv with that particular Python: 如果你真的可以导入bz2尝试使用特定的Python显式创建一个新的virtualenv:

virtualenv foo -p /path/to/system/python

You might want to do which python to check which Python you are using. 你可能想要做which python来检查你正在使用哪个Python。

So the reason why my compilation failed is either that I was missing bzip2-devel or that I gave the wrong path to ./configure when I did (not sure which of the two): 所以我的编译失败的原因要么是我缺少bzip2-devel要么是当我做错了(。不确定两者中的哪一个)时,我给了错误的./configure路径:

./configure --prefix=/home/deploy/.virtualenv/sentry

after which running 之后运行

make
make install

worked fine 工作得很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM