5

I download python2.6.6 source form http://www.python.org/getit/releases/2.6.6/ After that I run these commands ./configure make

I tried to import zlib but it says no module named zlib. How can install zlib module for it

After I tried installing python2.6.8 I got same error no zlib. While installing it I got below error

Failed to find the necessary bits to build these modules:

_bsddb             _curses            _curses_panel   
_hashlib           _sqlite3           _ssl            
_tkinter           bsddb185           bz2             
dbm                dl                 gdbm            
imageop            linuxaudiodev      ossaudiodev     
readline           sunaudiodev        zlib            

To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Failed to build these modules:

crypt              nis   
big
  • 1,888
  • 7
  • 28
  • 48
  • Why would you be installing an outdated version that has newer security-fix-only releases in the first place? – Wooble May 18 '12 at 14:44
  • possible duplicate of [no module named zlib](http://stackoverflow.com/questions/6169522/no-module-named-zlib) – Wooble May 18 '12 at 14:46
  • I have program which runs on python2.6 so I need zlib for it – big May 18 '12 at 14:50
  • At least install python 2.6.8. – Wooble May 18 '12 at 14:50
  • I tried but same problem.. I updated description – big May 18 '12 at 14:58
  • Is there a reason you're building Python yourself, rather than using a pre-built distribution? – NPE May 18 '12 at 15:00
  • Yes I have to build for a reason. I don't want it to install – big May 18 '12 at 15:02
  • Is there a way to use pre-built distribution without actually installing to /usr/lib/ I just want it to run from folder so that I just copy that folder to run anywhere by using ./python – big May 18 '12 at 15:07
  • See the duplicate question I linked to. The problem is you need the zlib development package installed on your machine. – Wooble May 18 '12 at 15:35
  • how can I download zblib development package without using apt-get – big May 18 '12 at 16:18
  • @bigbang why on earth would you not want to use apt-get? Are you doing this on a machine on which you don't have sudo rights? If apt-get is out of the question, I'd strongly suggest using PIP. – Louis Thibault May 18 '12 at 16:24
  • You can probably build it from source. – Wooble May 18 '12 at 17:39

4 Answers4

8

I tried following which helped me with some of these modules.
You have to edit setup.py.
Find the following lines in setup.py:

lib_dirs = self.compiler.library_dirs + [
   '/lib64', '/usr/lib64',
   '/lib', '/usr/lib',
   ]

For 64 bit
Add /usr/lib/x86_64-linux-gnu:

lib_dirs = self.compiler.library_dirs + [
   '/lib64', '/usr/lib64',
   '/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu',
   ]

For 32 bit
Add /usr/lib/i386-linux-gnu:

lib_dirs = self.compiler.library_dirs + [
   '/lib64', '/usr/lib64',
   '/lib', '/usr/lib', '/usr/lib/i386-linux-gnu',
   ]

Note x86_64-linux-gnu & i386-linux-gnu might be located somewhere else in your system so path accordingly.

Ater this you will be left with only following modules:

_bsddb             bsddb185           dbm             
gdbm               sunaudiodev  
big
  • 1,888
  • 7
  • 28
  • 48
  • I added both dirs, the 64bit version first, and it worked for me. Thanks! – Tobias Sep 04 '13 at 11:33
  • Adding '/usr/lib/x86_64-linux-gnu' solved my problem with zlib when trying to have 2 python versions in ubuntu 14.04. Thanks @big – 1vand1ng0 May 02 '15 at 11:50
  • Editing `setup.py` is not the solution intended. Instead, pass `CFLAGS` and `LDFLAGS` to `configure`, as @Dmitry suggests. – 0 _ Nov 11 '15 at 06:08
3

I solved the problem adding LDFLAGS=-L/usr/lib/x86_64-linux-gnu as configure parameter.

Dmitry Trofimov
  • 7,371
  • 1
  • 30
  • 34
2

I wrote a note for myself addressing your problem, might be helpful: python installation.

Do you really need bsddb and sunaudiodev modules? You might not want to since both are deprecated since python 2.6

Nemoden
  • 8,816
  • 6
  • 41
  • 65
1

I had this exact problem (exact python distribution as well) Dmity's answer almost worked... but after many hours searching I think I have found the issue (assuming you are using ubuntu 11.10 - 12.10)

Ok, so for me at least the problem stemmed from the fact that Ubuntu disabled SSLv2, so the workaround is fairly involved. Basically you have to delve into the source code and remove all references to SSLv2 before you build it, in addition to adding library paths to your setup file. I followed this tutorial and now I have a working virtualenv with python-2.6.8:

http://ubuntuforums.org/showthread.php?t=1976837

(The patches are fairly easy to implement without using patch) Hope this helps clear up the issues. PHEW

Daniel Kuntz
  • 405
  • 4
  • 11