Installing Python-2.7 on Ubuntu 10.4
Asked Answered
H

4

13

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
Hipolitohipp answered 28/10, 2010 at 21:14 Comment(0)
D
20

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.)

Damaris answered 28/10, 2010 at 22:14 Comment(0)
T
9

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.

Tervalent answered 19/10, 2011 at 10:53 Comment(1)
My personal preference is to modify python distutils to look in the right place. This command should do the trick: /bin/sed -i -e "/self.library_dirs = /s#[]#[\'/usr/lib/x86_64-linux-gnu\', \'/lib/x86_64-linux-gnu\']#" /usr/lib/python2.7/distutils/command/build_ext.pyForsaken
B
2

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.

Biometry answered 28/10, 2010 at 21:19 Comment(0)
H
1

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

Hypersensitize answered 24/11, 2011 at 12:50 Comment(1)
On Xubuntu 12.04.1, I had to install zlib1g-dev and dpkg-dev.Dominick

© 2022 - 2024 — McMap. All rights reserved.