gpt4 book ai didi

python - 在 Ubuntu 10.4 上安装 Python-2.7

转载 作者:太空狗 更新时间:2023-10-29 17:23:45 25 4
gpt4 key购买 nike

我似乎无法正确安装 zlib,我在 Ubuntu10.4 上从源代码安装了 Python

'########编辑#####################
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

最佳答案

你不需要zlibc,它完全是另外一回事。您需要 zlib1g(肯定已经安装),并且正如 Luper 提到的那样,“开发”包是 zlib1g-dev

基于 Debian 的 Linux 发行版将每个 C 库拆分为一个单独的运行时二进制包和一个开发包,该开发包提供要在编译时包含的 header 。如果你想从依赖库的源代码编译一些东西,你需要这两个包。这有点烦人,但考虑到像 Ubuntu 这样的库提供的库数量惊人地庞大,这可能是不可避免的。

确保你引入了你可能希望 Python 也能使用的其他 -dev 包,例如 libexpat1-devlibdb4.8 -devlibncurses5-devlibreadline6-dev(使用没有 readline 的 Python 解释器很痛苦!)。然后,您必须重新编译 Python 才能利用它们。

(或者如果你不想被打扰,你可能会忘记安装工具,然后自己解压任何终端应用程序并将其放入站点包或任何地方。不得不说我不是鸡蛋的忠实粉丝.)

关于python - 在 Ubuntu 10.4 上安装 Python-2.7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4047212/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com