Problem scenario
You are trying to install Python 3 but you get a message about zlib. This is the full message:
rm /usr/local/lib/python3.9/lib-dynload/_sysconfigdata__linux_x86_64-linux-gnu.py
rm -r /usr/local/lib/python3.9/lib-dynload/__pycache__
/bin/install -c -m 644 ./Misc/python.man \
/usr/local/share/man/man1/python3.9.1
if test "xupgrade" != "xno" ; then \
case upgrade in \
upgrade) ensurepip="--altinstall --upgrade" ;; \
install|*) ensurepip="--altinstall" ;; \
esac; \
./python -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Traceback (most recent call last):
File "<frozen zipimport>", line 520, in _get_decompress_func
ModuleNotFoundError: No module named 'zlib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen zipimport>", line 568, in _get_data
File "<frozen zipimport>", line 523, in _get_decompress_func
zipimport.ZipImportError: can't decompress data; zlib not available
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/Python-3.9.0a1/Lib/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/bin/Python-3.9.0a1/Lib/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/usr/bin/Python-3.9.0a1/Lib/ensurepip/__main__.py", line 5, in <module>
sys.exit(ensurepip._main())
File "/usr/bin/Python-3.9.0a1/Lib/ensurepip/__init__.py", line 203, in _main
return _bootstrap(
File "/usr/bin/Python-3.9.0a1/Lib/ensurepip/__init__.py", line 122, in _bootstrap
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/usr/bin/Python-3.9.0a1/Lib/ensurepip/__init__.py", line 30, in _run_pip
import pip._internal
File "<frozen zipimport>", line 241, in load_module
File "<frozen zipimport>", line 709, in _get_module_code
File "<frozen zipimport>", line 570, in _get_data
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [Makefile:1200: altinstall] Error 1
Solution
Run this:sudo yum -y install zlib-devel
(If you get a "yum command not found" error, go to this site.)