pip: zipimport.ZipImportError

When I run the command “python get-pip.py”,It alerts that as below:

Traceback (most recent call last):
  File "../get-pip.py", line 17474, in <module>
    main()
  File "../get-pip.py", line 17466, in main
    bootstrap(tmpdir=tmpdir)
  File "../get-pip.py", line 17406, in bootstrap
    import pip
zipimport.ZipImportError: can't decompress data; zlib not available

How to do that?Thank you!

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 24 (7 by maintainers)

Most upvoted comments

1.Install the zlib the newest version 2.Then complie python again and run a line ./configure --prefix=/root/Python-2.7.8 --with-zlib-dir=/usr/local/lib

Thank you, I have made it!

@andy15703166 “1.Install the zlib the newest version” How to do this?

also

$ ./configure --prefix= --with-zlib-dir=/usr/local/lib
configure: WARNING: unrecognized options: --with-zlib-dir

btw

$ sudo yum install zlib
Loaded plugins: ulninfo
Setting up Install Process
Package zlib-1.2.3-29.el6.i686 already installed and latest version 
Nothing to do

What worked for me (@ vagrant oel65-i386-plain) was (not completely but at least killed zlib issue) was:

sudo yum install zlib-devel
./configure
make
sudo make install

python2.7 get-pip.py does not complain about zlib not being there (it complains now about SSL but that is not this story)

Looks like your Python was built without zip support. Presumably it’s a custom build? You need that support for get-pip to work.

The error: zipimport.ZipImportError: can’t decompress data; zlib not available I meet the same problem while using the command “python get-pip.py”. python: 2.7.12 os: Centos 6.5

  1. I think that I must lose the module zlib. So, I using the command “yum install zlib-devel”. I try the command “python get-pip.py” again. The problem is still be there.
  2. I try reinstall python again.
  3. I try the command “python get-pip.py” again. The problem is solved. thanks all !

In the python source folder ./configure --prefix= --with-zlib-dir=/usr/local/lib and make && make install Should be OK

@hrdcore0x1 maybe you want --with-libs instead of --with-lib-dir

Make sure you have zlib (+development headers) package installed.

can you elaborate more the solution? i am facing the same problem and when trying the command ./configure --prefix=/root/Python-2.7.8 --with-zlib-dir=/usr/local/lib i get unrecognized command --with-lib-dir

As I guess you found out (just mentioning it here in case anyone later finds this issue when searching) you just need the relevant libraries available when building Python (I think it’s just zlib, but I’m not completely sure on that)

@NivaldoTeixeira directly inside the unzipped python sources folder. This is if you are building your python executable / installation from scratch. https://github.com/python/cpython/blob/master/configure is the file in SCM.