Installed python from source gives "ZipImportError, zlib not available" (Working behind firewall)

Issues related to applications and software problems
Post Reply
shanedora
Posts: 9
Joined: 2018/10/17 21:40:17

Installed python from source gives "ZipImportError, zlib not available" (Working behind firewall)

Post by shanedora » 2018/10/18 17:47:43

I need to install python from source on this system that sits behind a firewall. I have root privileges but I don't have network access in the since to be running yum commands. I downloaded the tarball for python3.6 to my home directory then untar'd it, cd'd into it and ran the following three commands...

./configure
sudo make
sudo make install

During the <sudo make install> process I get an error saying...

Code: Select all

zipimport.ZipImportError: can't decompress data; zlib not available
How can I resolve this or is it possible in my circumstance?

I took a stab at this by going to the zlib homepage and downloading the tar.gz for it. I then scp'd this tar.gz over to the firewall protected system and performed the following from my home folder

Code: Select all

./configure --prefix=/my/home/folder
make
make install
Everything went smoothly but when I went to rerun the install commands for python again it still complained with the same error. I did a <sudo make clean> and tried again still the same error. Since then I've removed the uncompressed tar.gz for zlib and I'm currently sitting here trying to decide what to do. :roll:

UPDATE:

I searched for the string zlib as such...
sudo find / -iname "*zlib*"

It gave me the following output...

Code: Select all

/lib/modules/2.6.32-504.12.2.el6.x86_64/kernel/lib/zlib_deflate
/lib/modules/2.6.32-504.12.2.el6.x86_64/kernel/lib/zlib_deflate/zlib_deflate.ko
/lib/modules/2.6.32-504.12.2.el6.x86_64/kernel/crypto/zlib.ko
/lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/lib/zlib_deflate
/lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/lib/zlib_deflate/zlib_deflate.ko
/lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/crypto/zlib.ko
/lib/modules/2.6.32-642.4.2.el6.x86_64/kernel/lib/zlib_deflate
/lib/modules/2.6.32-642.4.2.el6.x86_64/kernel/lib/zlib_deflate/zlib_deflate.ko
/lib/modules/2.6.32-642.4.2.el6.x86_64/kernel/crypto/zlib.ko
/var/lib/yum/yumdb/z/a1ef9a11eb432f241870b1cdd604a408ca26ffb5-zlib-1.2.3-29.el6-x86_64
/var/lib/yum/yumdb/z/90e55202493675b25b3b93c55529238ac5d4f1ea-zlib-1.2.3-29.el6-i686
/var/lib/yum/yumdb/p/878bba6f7671e991d3cfea0a1ae6c67d4da1664f-perl-IO-Zlib-1.09-141.el6_7.1-x86_64
/var/lib/yum/yumdb/p/f24360cc52822108e3cdb393596b69ba8d63fcfe-perl-Compress-Zlib-2.021-141.el6_7.1-x86_64
/var/lib/yum/yumdb/p/e3107f72f6d87d660f16697d84b753a83dca2317-perl-Compress-Raw-Zlib-2.021-141.el6_7.1-x86_64
/var/lib/yum/yumdb/p/80461147cdc3d854a5bb6c55ce1ed21751678e68-perl-IO-Compress-Zlib-2.021-141.el6_7.1-x86_64
/home/j2ops/python36/Python-3.6.6/Doc/library/zlib.rst
/home/j2ops/python36/Python-3.6.6/Modules/zlibmodule.c
/home/j2ops/python36/Python-3.6.6/Modules/zlib
/home/j2ops/python36/Python-3.6.6/Modules/zlib/zlib.pc.in
/home/j2ops/python36/Python-3.6.6/Modules/zlib/gzlib.c
/home/j2ops/python36/Python-3.6.6/Modules/zlib/zlib.3
/home/j2ops/python36/Python-3.6.6/Modules/zlib/zlib.map
/home/j2ops/python36/Python-3.6.6/Modules/zlib/zlib.h
/home/j2ops/python36/Python-3.6.6/Modules/clinic/zlibmodule.c.h
/home/j2ops/python36/Python-3.6.6/Lib/encodings/zlib_codec.py
/home/j2ops/python36/Python-3.6.6/Lib/test/test_zlib.py
/lib64/rsyslog/lmzlibw.so
/usr/lib/ruby/site_ruby/1.8/puppet/feature/zlib.rb
/usr/share/man/man3/Compress::Zlib.3pm.gz
/usr/share/man/man3/IO::Zlib.3pm.gz
/usr/share/man/man3/Compress::Raw::Zlib.3pm.gz
/usr/share/doc/python-docs-2.6.6/html/_sources/library/zlib.txt
/usr/share/doc/python-docs-2.6.6/html/library/zlib.html
/usr/share/doc/zlib-1.2.3
/usr/share/doc/python-paramiko-1.7.5/docs/paramiko.compress.ZlibCompressor-class.html
/usr/share/doc/python-paramiko-1.7.5/docs/paramiko.compress.ZlibDecompressor-class.html
/usr/share/perl5/IO/Zlib.pm
/usr/local/lib/python3.6/test/__pycache__/test_zlib.cpython-36.opt-1.pyc
/usr/local/lib/python3.6/test/__pycache__/test_zlib.cpython-36.opt-2.pyc
/usr/local/lib/python3.6/test/__pycache__/test_zlib.cpython-36.pyc
/usr/local/lib/python3.6/test/test_zlib.py
/usr/local/lib/python3.6/encodings/zlib_codec.py
/usr/local/lib/python3.6/encodings/__pycache__/zlib_codec.cpython-36.opt-1.pyc
/usr/local/lib/python3.6/encodings/__pycache__/zlib_codec.cpython-36.opt-2.pyc
/usr/local/lib/python3.6/encodings/__pycache__/zlib_codec.cpython-36.pyc
/usr/local/lib/python2.7/test/test_zlib.pyc
/usr/local/lib/python2.7/test/test_zlib.pyo
/usr/local/lib/python2.7/test/test_zlib.py
/usr/local/lib/python2.7/encodings/zlib_codec.py
/usr/local/lib/python2.7/encodings/zlib_codec.pyo
/usr/local/lib/python2.7/encodings/zlib_codec.pyc
/usr/lib64/python2.6/lib-dynload/zlibmodule.so
/usr/lib64/python2.6/encodings/zlib_codec.py
/usr/lib64/python2.6/encodings/zlib_codec.pyo
/usr/lib64/python2.6/encodings/zlib_codec.pyc
/usr/lib64/ruby/1.8/x86_64-linux/zlib.so
/usr/lib64/perl5/auto/Compress/Zlib
/usr/lib64/perl5/auto/Compress/Raw/Zlib
/usr/lib64/perl5/auto/Compress/Raw/Zlib/Zlib.so
/usr/lib64/perl5/Compress/Zlib.pm
/usr/lib64/perl5/Compress/Raw/Zlib.pm
/usr/lib64/perl5/IO/Compress/Zlib
/opt/Python-2.7.6/Modules/zlib
/opt/Python-2.7.6/Modules/zlib/zlib.h
/opt/Python-2.7.6/Modules/zlib/zlib.3
/opt/Python-2.7.6/Modules/zlibmodule.c
/opt/Python-2.7.6/Demo/zlib
/opt/Python-2.7.6/Demo/zlib/zlibdemo.py
/opt/Python-2.7.6/Lib/test/test_zlib.py
/opt/Python-2.7.6/Lib/encodings/zlib_codec.py
/opt/Python-2.7.6/Doc/library/zlib.rst
Not sure how to proceed.

lightman47
Posts: 741
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: Installed python from source gives "ZipImportError, zlib not available" (Working behind firewall)

Post by lightman47 » 2018/10/18 21:48:13

Are you running CentOS 6 or 7? It makes a big difference.

When you searched for zlib, it returned results for "el6" not CentOS 7 (el7). The systems are completely different.
"The more I learn, the behinder I get"

User avatar
TrevorH
Forum Moderator
Posts: 23897
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Installed python from source gives "ZipImportError, zlib not available" (Working behind firewall)

Post by TrevorH » 2018/10/19 07:43:05

No, don't do it.

Really, if you install python from source and replace the system python that we ship then you will be reinstalling your system shortly afterwards. All the tooling we ship depends on the exact version of python that we ship - yum will stop working for a start.

If you need newer python versions then get one of the ones built by e.g. the IUS repo that install in parallel with the system python.

That also looks like you have a CentOS 6 system not a 7 one so I will move this topic to the correct CentOS 6 forums.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

shanedora
Posts: 9
Joined: 2018/10/17 21:40:17

Re: Installed python from source gives "ZipImportError, zlib not available" (Working behind firewall)

Post by shanedora » 2018/10/19 15:13:44

@Trevor

Would you help me understand why you so strictly suggest I don't install another python release. First, if you need python3 then one has no choice. However, installing from source doesn't mean you'll overwrite the system python if you're cautious about how you're doing it. I can tell the <configure> script to install anywhere I want (even the home directory if I choose). I can pass the <--altinstall> flag to prevent the install from overwriting the system configured python. I can go even farther to create soft links to new installed versions of python or just type out the full path in general. Therefore, would you be so kind to help me understand why you suggest all this is suddenly invalid or simple not a "great" option?

User avatar
TrevorH
Forum Moderator
Posts: 23897
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Installed python from source gives "ZipImportError, zlib not available" (Working behind firewall)

Post by TrevorH » 2018/10/19 15:29:35

Most people we get here who've installed a different python don't use an altinstall, they just blindly go ahead and splat all over the current version and since there was no info to the contrary in your initial post, I tend to err on the side of caution and say "Stop!" first and find out more after.

If you want to and know how to install it so that the system python is untouched then go ahead. However, you might find it easier in the long run to mirror the IUS repo python36 package set to an internal yum repo that your system(s) can get to and that way the install will be kept up to date without you needing to do anything. Nor will you have to have umpteen development packages and a compiler etc installed on what are presumably production systems. If you don't want to do that then perhaps look at packaging your install to avoid the dev toolchain dependency.

As for the bit about CentOS 6 vs 7, the output you showed for searching for zlib lists directories for kernel modules in /lib/modules/2.6.32... and that is not a CentOS 7 kernel, it's one from 6. In fact, it's 3 from el6: 2.6.32-504.12.2.el6, 2.6.32-573.8.1.el6 and 2.6.32-642.4.2.el6 (none of which are current BTW, 6.10 uses 2.6.32-754* kernels).
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

Post Reply