在 Ubuntu 10.4 上安装 Python-2.7

发布于 2024-09-29 19:45:20 字数 3140 浏览 8 评论 0原文

我似乎无法正确安装 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

I can't seem to install zlib properly, I installed Python from source on Ubuntu10.4

'######## edit #####################
bobince and Luper helped.
Make sure you install these packages and then recompile Python:
sudo aptitude install zlib1g-dev libreadline6-dev libdb4.8-dev libncurses5-dev
'#################################

After installation, I attempted to install 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  

I then installed 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  

Before recompiling Python:

but setuptools still won't install:

$ 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  

I'm baffled.

I checked my permissions:

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

I noticed I'd added an extra step, so I refactored it:

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  

So now, Python2.7 should be the default version, but it still fails.

$ 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  

Where should zlib be located to work properly?

$ 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

太阳男子 2024-10-06 19:45:21

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

基于 Debian 的 Linux 发行版将每个 C 库分成一个单独的运行时二进制包和一个开发包,后者提供编译时包含的标头。如果您想从依赖于该库的源代码编译某些内容,则需要这两个包。这有点令人烦恼,但考虑到 Ubuntu 等提供的库数量惊人,这可能是不可避免的。

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

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

You don't want zlibc, it's something else completely. You want zlib1g (which will certainly be installed already) and, as Luper mentioned, the ‘development’ package which is zlib1g-dev.

Debian-based Linux distros split each C library into a separate runtime binary package and a development package which delivers the headers for inclusion at compile time. If you want to compile something from source that relies on the library you need both packages. It's a bit of an annoyance, but probably inevitable given the staggeringly enormous number of libs the likes of Ubuntu deliver.

Make sure you bring in other -dev packages you might want Python to be able to use, too, such as libexpat1-dev, libdb4.8-dev, libncurses5-dev and libreadline6-dev (using the Python interpreter without readline is painful!). You'll then have to recompile Python to take advantage of them.

(Or if you can't be bothered, you might forget setuptools, and just unpack whatever end app it is yourself and drop it in the site-packages or wherever. Have to say I'm not a huge fan of eggs.)

私藏温柔 2024-10-06 19:45:21

请记住,对于 x64 架构,Ubuntu 使用名为 /lib/x86_64-linux-gnu 的目录。如果您使用该体系结构,您需要创建一个符号链接:

$ sudo ln -s /lib/x86_64-linux-gnu/libz.so.1 /lib/libz.so

此外,您应该对其他共享库执行相同的操作。

Keep in mind that Ubuntu is using a directory called /lib/x86_64-linux-gnu for x64 architectures. If you are using that architecture you need to create a symbolic link:

$ sudo ln -s /lib/x86_64-linux-gnu/libz.so.1 /lib/libz.so

Also, you should do same thing for others shared libraries.

风和你 2024-10-06 19:45:21

从源代码配置和编译 Python 时,请确保安装了 zlib 的开发包(以及您需要的标准模块所依赖的任何其他库)。

Make sure the dev package of zlib (and any other lib that a standard module you need depends on) is installed when configuring and compiling Python from source.

悍妇囚夫 2024-10-06 19:45:21

在配置和编译Python之前尝试安装dpkg-dev。这将在系统上安装 dpkg-architecture 可执行文件,Python 使用该可执行文件(请参阅 setup.py)来确定 libz.so 库的位置。有关更多详细信息,请参阅 http://fnch.users.sourceforge.net/pythononubuntu1004.html

Try to install dpkg-dev before configuring and compiling Python. This will install the dpkg-architecture executable on the system, which Python uses (see setup.py) to determine where the libz.so library is. For more details see http://fnch.users.sourceforge.net/pythononubuntu1004.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文