4

I am trying to install python 3.2, and to get setuptools and pip in python 3.2. Everything seems to work right in python 2.7. However when I try to install setuptools using this code wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python3.2 I get the following error

Extracting in /tmp/tmpcwnav_
Traceback (most recent call last):
  File "<stdin>", line 332, in <module>
  File "<stdin>", line 329, in main
  File "<stdin>", line 51, in _install
  File "/usr/local/lib/python3.2/contextlib.py", line 28, in __enter__
    return next(self.gen)
  File "<stdin>", line 101, in archive_context
  File "/usr/local/lib/python3.2/zipfile.py", line 1004, in extractall
    self.extract(zipinfo, path, pwd)
  File "/usr/local/lib/python3.2/zipfile.py", line 992, in extract
    return self._extract_member(member, path, pwd)
  File "/usr/local/lib/python3.2/zipfile.py", line 1035, in _extract_member
    source = self.open(member, pwd=pwd)
  File "/usr/local/lib/python3.2/zipfile.py", line 978, in open
    close_fileobj=not self._filePassed)
  File "/usr/local/lib/python3.2/zipfile.py", line 487, in __init__
    self._decompressor = zlib.decompressobj(-15)
AttributeError: 'NoneType' object has no attribute 'decompressobj'

Based on some googling, it looks like I am getting the problem because zlib has not been installed. I do not have this problem when trying to install setuptools for python 2.7. I went into python 3.2 and tried to import zlib and got an error message when I tried that. I also tried to do sudo apt-get install zlib and got the error message E: Unable to locate package zlib. I did not get error messages when I tried sudo apt-get install zlib1g or sudo apt-get install zlib1g-dev` I really have no idea what's going on. How do I get zlib for python 3.2 (or otherwise fix this problem?)

5

Your problem seems to be you compiled Python without support for zlib. Make sure you have zlib-devel installed (sudo apt-get install zlib1g-dev) before compiling Python. There's nothing wrong with using Python compiled by you in addition or instead of the system one. However you have to remember to be explicit when invoking Python and invoke the one you intend to use by specifying full path like /usr/local/bin/python instead of plain python. Alternatively you can add (/usr/local/bin/) to your PATH before /usr/bin/ so that when you type python system runs your compiled Python.

0

Your problem is here:

File "/usr/local/lib/python3.2/zipfile.py", line 487, in __init__

you aren't using your system python binary. Make sure you are using your system binaries with:

wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo /usr/bin/python3

It should work.

  • Thanks! Do I have to somehow uninstall the old version first, or can I just cut and paste the command in> – Ravi Oct 27 '14 at 22:16
  • @Ravi is recommendable that you remove that version of your system, to prevent problems in the future. – Braiam Oct 27 '14 at 22:17
  • I installed it from the source, and it looks like there is no easy way to uninstall it. In the short run, is there any easy way for me to make sure that the right version of Python is being used? – Ravi Oct 27 '14 at 22:34
  • Or alternatively, is there any way for me to tell the computer to use the system binaries without reinstalling python 3.2? – Ravi Oct 27 '14 at 22:38
  • @Ravi use the complete path as I'm doing in the post. – Braiam Oct 27 '14 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.