我似乎无法正确安装zlib,我在Ubuntu10.4上从源代码安装了Python
'######## edit #####################
bobince和Luper帮忙
确保安装这些软件包,然后重新编译Python:
sudo aptitude install zlib1g-dev libreadline6-dev libdb4.8-dev libncurses5-dev
“#################################
安装后,我尝试安装setuptools.py
$ sh setuptools-0.6c11-py2.7.egg
Traceback (most recent call last):
File "<string>", line 1, in <module>
zipimport.ZipImportError: can't decompress data; zlib not available
然后我安装了zlib:
$ sudo aptitude install zlibc
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
The following NEW packages will be installed:
zlibc
0 packages upgraded, 1 newly installed, 0 to remove and 44 not upgraded.
Need to get 74.6kB of archives. After unpacking 299kB will be used.
Writing extended state information... Done
Get:1 http://archive.ubuntu.com/ubuntu/ lucid/universe zlibc 0.9k-4.1 [74.6kB]
Fetched 74.6kB in 0s (108kB/s)
Selecting previously deselected package zlibc.
(Reading database ... 19824 files and directories currently installed.)
Unpacking zlibc (from .../zlibc_0.9k-4.1_amd64.deb) ...
Processing triggers for man-db ...
Setting up zlibc (0.9k-4.1) ...
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
在重新编译Python之前:
但是setuptools仍然无法安装:
$ sh setuptools-0.6c11-py2.7.egg
Traceback (most recent call last):
File "<string>", line 1, in <module>
zipimport.ZipImportError: can't decompress data; zlib not available
我很困惑。
我检查了我的权限:
lrwxrwxrwx 1 root 18 Oct 28 18:19 /usr/bin/python -> /usr/bin/python2.7
lrwxrwxrwx 1 root 24 Oct 28 18:26 /usr/bin/python2.7 -> /usr/local/bin/python2.7
lrwxrwxrwx 1 root 9 Oct 28 15:13 /usr/bin/python2 -> python2.6
-rwxr-xr-x 1 root 2613296 Apr 16 2010 /usr/bin/python2.6
我注意到我添加了一个额外的步骤,所以我重构了它:
llrwxrwxrwx 1 root 24 Oct 28 18:33 /usr/bin/python -> /usr/local/bin/python2.7
lrwxrwxrwx 1 root 9 Oct 28 15:13 /usr/bin/python2 -> python2.6
-rwxr-xr-x 1 root 2613296 Apr 16 2010 /usr/bin/python2.6
现在,Python2.7应该是默认版本,但它仍然失败。
$ sh setuptools-0.6c11-py2.7.egg --prefix=/usr/local/bin/python2.7
Traceback (most recent call last):
File "<string>", line 1, in <module>
zipimport.ZipImportError: can't decompress data; zlib not available
zlib应该放在哪里才能正常工作?
$ find / -name zlib 2>/dev/null
/home/username/sources/Python-2.7/Modules/zlib
/home/username/sources/Python-2.7/Demo/zlib
username@servername Thu Oct 28 18:43:17 ~/sources
$ find / -name zlibc 2>/dev/null
/usr/share/lintian/overrides/zlibc
/usr/share/doc/zlibc
答案 0 :(得分:20)
你不想要zlibc
,这完全是另一回事。你想要zlib1g
(肯定会已经安装),并且正如Luper所提到的那样,是'{1}}的'开发'包。
基于Debian的Linux发行版将每个C库拆分为一个单独的运行时二进制包和一个开发包,该包在编译时提供包含的头。如果你想从依赖库的源代码编译,你需要两个包。这有点令人烦恼,但可能是不可避免的,因为Ubuntu提供了巨大数量的库。
确保您引入了其他可能希望Python能够使用的zlib1g-dev
个软件包,例如-dev
,libexpat1-dev
,libdb4.8-dev
和{{1 (使用没有readline的Python解释器很痛苦!)。然后,您将不得不重新编译Python以利用它们。
(或者,如果你不能打扰,你可能会忘记setuptools,只需将自己的最终应用程序解压缩并将其放入网站包装或任何地方。不得不说我不是鸡蛋的忠实粉丝。)
答案 1 :(得分:9)
请注意, Ubuntu 正在为 x64 架构使用名为 / lib / x86_64-linux-gnu 的目录。如果您正在使用该架构,则需要创建符号链接:
$ sudo ln -s /lib/x86_64-linux-gnu/libz.so.1 /lib/libz.so
此外,您应该为其他共享库做同样的事情。
答案 2 :(得分:2)
在从源代码配置和编译Python时,确保安装了zlib的dev包(以及您需要的标准模块依赖的任何其他lib)。
答案 3 :(得分:1)
在配置和编译Python之前,尝试安装dpkg-dev。这将在系统上安装dpkg-architecture可执行文件,Python使用它(参见setup.py)来确定libz.so库的位置。有关详细信息,请参阅http://fnch.users.sourceforge.net/pythononubuntu1004.html