import zlib ImportError: No module named zlib [dup

2020-07-18 03:07发布

# pythonbrew venv create django1.5
Creating `django1.5` environment into /usr/local/pythonbrew/venvs/Python-2.7.3
Traceback (most recent call last):
File "/usr/local/pythonbrew/etc/virtualenv/virtualenv.py", line 19, in <module>
import zlib
ImportError: No module named zlib

What should I do?? I want to import zlib.

And I aready install zlib *

# rpm -qa |grep zlib
zlib-1.2.5-7.fc17.i686
zlib-devel-1.2.5-7.fc17.i686

UPDATE:

# uname -a
Linux localhost.localdomain 3.6.10-2.fc17.i686 #1 SMP Tue Dec 11 18:33:15 UTC 2012 i686 i686 i386 GNU/Linux
# cat /etc/issue
Fedora release 17 (Beefy Miracle)
Kernel \r on an \m (\l)

2条回答
迷人小祖宗
2楼-- · 2020-07-18 03:42

Check PYTHONPATH variable. It is possible that this variable is set incorrectly when django start. From other hands django1.5 use incorect path for searching library. The second reson may be zlib was installed in non-default path

查看更多
冷血范
3楼-- · 2020-07-18 03:48

This is what I did (I only needed zlib).

Run this first: pythonbrew uninstall x.x.x

Then run this: sudo apt-get install zlib1g-dev libssl-dev python-dev (add packages here)

Now this: pythonbrew install x.x.x

Follow the tail using this command in another terminal window/tab (they provide a command to follow the tail).

If you see no errors in the tail, you should have zlib (and other packages) successfully working with pythonbrew.

You should now be able to create a venv.

查看更多
登录 后发表回答