35.NO module named zlib

Configure and compile Python with Zlib

简单描述下环境,

在win7下用VBox虚拟了个centos6.4,因为centos带的是python2.6的,做了个升级装成2.7.5。然后有用ln -s做连接到/usr/bin ,只要运行python调用的就是2.7不是2.6了。为了方便想用virtualenv虚拟个2.7出来,一切就绪后,virtualenv XXX就报错了,截图如上。我rpm -qa | grep zlib发现时有装的zlib。并且我重新yum装下也是不行。


从stackoverflow上看了下说configure --with-zlib,我这样试了下,警告unrecognized options.

最后从国外一blog上看到这篇文章

I just spent an hour trying to figure this out, AGAIN! To compile Zlib support into your Python interpreter, do this:

1. Install the Zlib-dev package for your distribution. (you probably have zlib already, but not the dev package)
On Ubuntu it’s called ‘zlib1g-dev’, on others it might just be: zlib-dev or zlib-devel. Do a search on your distro package lists to find it.
You should end up with a ‘zlib.h’ file in your system. In mine, Ubuntu, I have /usr/include/zlib.h

2. Get your python sources to compile and run the configure script like so:
./configure –with-zlib=/usr/include

See there that I included the ‘/usr/include’ directory to find zlib.h in? After the make && make install it worked great!

Keep in mind your mileage may vary, but this might help I hope. More importantly, now I can remember how I did this! :)


注:cnetos下是安装zlib跟zlib-devel,最后不要yum,手动make,make install。好了后把python2.7再重启编译下安装,KO!!

转载于:https://my.oschina.net/quanpower/blog/149936

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值