import zlib ImportError: No module named zlib [duplicate]

社会主义新天地 提交于 2019-12-06 05:28:56

问题


# 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)

回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/14532742/import-zlib-importerror-no-module-named-zlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!