在Ubuntu 10.4上安装Python-2.7

我似乎无法正确安装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>",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>",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库分成一个单独的运行时二进制包和一个开发包,它在编译时提供包含头文件.如果您想从依赖于库的源编译某些东西,您需要这两个包.这是一个烦恼,但可能是不可避免的,因为Ubuntu提供的这些非常庞大的lib数量.

确保你引入了你可能希望Python能够使用的其他-dev软件包,如libexpat1-dev,libdb4.8-dev,libncurses5-dev和libreadline6-dev(使用没有readline的Python解释器是痛苦的! ).然后,您将需要重新编译Python以利用它们.

(或者如果你不能打扰,你可能会忘记安装工具,只需打开它自己的任何终端应用程序,并将其放在网站包或任何地方.不得不说我不是一个巨大的鸡蛋粉丝.)

相关文章

文章浏览阅读2.3k次,点赞4次,收藏22次。最近安装了CARLA预...
文章浏览阅读6.3k次,点赞5次,收藏15次。在清华镜像中下载U...
文章浏览阅读5k次。linux环境, python3.7.问题描述: 安装...
文章浏览阅读4.2k次,点赞4次,收藏17次。要安装这个 standa...
文章浏览阅读894次,点赞51次,收藏31次。在安卓使用vscode主...