Python 3 installation exits without installing zlib and pip. How can I fix this?

edit 2: I cannot use sudo.


I followed this guide. After running 'make' the installation exited with:

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2                  _curses               _curses_panel      
_dbm                  _gdbm                 _lzma              
_sqlite3              _ssl                  _tkinter           
readline              zlib                                     
To find the necessary bits, look in setup.py in detect_modules() for the module's name.'

File "/home/sites/3b/4/40b84bb780/Python-
3.6.4/Lib/ensurepip/__main__.py", line 5, in <module>
File "/home/sites/3b/4/40b84bb780/Python-
3.6.4/Lib/ensurepip/__init__.py", line 204, in _main
File "/home/sites/3b/4/40b84bb780/Python-
3.6.4/Lib/ensurepip/__init__.py", line 117, in _bootstrap
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/home/sites/3b/4/40b84bb780/Python-
3.6.4/Lib/ensurepip/__init__.py", line 27, in _run_pip
import pip
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [altinstall] Error 1
  • Can you post the installation log and the command you ran? – Kevin Lemaire Jan 15 '18 at 11:08
  • I followed thislink After running 'make altinstall' the installation exited with: – spheroid Jan 15 '18 at 11:37
  • You may complete your question, it's more efficient then comments. – Kevin Lemaire Jan 15 '18 at 11:42
  • I've edited the question. I added part of the log. – spheroid Jan 15 '18 at 11:50
  • Installing software without sudo often requires compiling from source. – Weijun Zhou Jan 15 '18 at 13:31

zlib is needed to complete the installation.

Regarding edit2: You may try with RPM. Download the zlib-devel rpm and then run rpm -ivh package.rpm

To install it on CentOS: sudo yum install zlib-devel

Then run the make command again.

  • I do not have sudo access. It's a shared hosting server. – spheroid Jan 15 '18 at 12:02
  • Can you try the edit with rpm? – Kevin Lemaire Jan 15 '18 at 12:26
  • I had tried to do that but I got an error - 'error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)'. according to this thread , you need to use it with sudo? – spheroid Jan 15 '18 at 12:37
  • This means you also need sudo access for rpm command. It's not always the case. – Kevin Lemaire Jan 15 '18 at 13:04

You can try the below; make altinstallto try to get around any sudo permission needed to replace the default python binary file in /usr/bin/python

yum install gcc
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0a1.tgz
tar xzf Python-3.7.0a1.tgz
cd Python-3.7.0a1
make altinstall
  • 1
    yum is sudo restricted so first line won't run – Kevin Lemaire Jan 15 '18 at 16:05
  • Sounds like you need to reach out to your system admin. Probably a reason for the account you are using to not has sudo access. – Govna Jan 15 '18 at 18:34

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