Python 3.12 installation error ModuleNotFoundError: No module named 'zlib' on ubi9

Python 3.12 install in ubi8 no problem

But Python 3.12 installation error ModuleNotFoundError: No module named ‘zlib’ on ubi9

The zlib module is an optional standard library module, as it requires third-party libraries during the build process. Are you building from source, it may be that the image no longer provides the required library by default?

Both ubi8 and ubi9 contains zlib. And both ubi8 and ubi9 don’t have zlib-devel

Works for me:

$ podman run -ti --rm registry.access.redhat.com/ubi9/ubi
[root@a08860e539a9 /]# dnf install -y python3.12
...
[root@a08860e539a9 /]# python3.12 -c 'import zlib; print(zlib)'
<module 'zlib' from '/usr/lib64/python3.12/lib-dynload/zlib.cpython-312-x86_64-linux-gnu.so'>
[root@a08860e539a9 /]# rpm -qf /usr/lib64/python3.12/lib-dynload/zlib.cpython-312-x86_64-linux-gnu.so
python3.12-libs-3.12.9-1.el9_6.2.x86_64

In our case, we download the python from Index of /ftp/python/ , and install it