compiled python3.10 is unable to find _ssl
![](https://secure.gravatar.com/avatar/4026093fcab95eb45ce347cf3f635fad.jpg?s=120&d=mm&r=g)
I am having compilation issues again with python3.10 with ssl . The ./configure was invoked with ssl options and ssl modules seems to be build successfully. """ The following modules found by detect_modules() in setup.py, have been built by the Makefile instead, as configured by the Setup files: _abc _hashlib _ssl pwd time """ However, when I do import ssl from python, I get the error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/shared/Builds/Python-3.10.0/lib/python3.10/ssl.py", line 98, in <module> import _ssl # if we can't import it, let the error propagate ModuleNotFoundError: No module named '_ssl' I can't find _ssl.so in build or install directory. Thanks -S
![](https://secure.gravatar.com/avatar/1ecbc9244c44128e90038a6e0376663b.jpg?s=120&d=mm&r=g)
Your configure script did pick up openssl as the support version was not found. What is your operating system? Make sure you have supported version of ssl. Python requires openssl 1.1.1 or higher. On Mac, I had to use brew to install it and --with-openssl flag. On some linux machines, I have had to download openssl, compile it, and point my the configure script to (location I compiled openssl). CFLAGS="-I$HOME/openssl/include" LDFLAGS="-L$HOME/openssl/lib" Thank you, Senthil On Mon, Oct 18, 2021 at 08:16:01PM +0530, Sandeep Gupta wrote:
I am having compilation issues again with python3.10 with ssl .
The ./configure was invoked with ssl options and ssl modules seems to be build successfully.
""" The following modules found by detect_modules() in setup.py, have been built by the Makefile instead, as configured by the Setup files: _abc _hashlib _ssl pwd time """
However, when I do import ssl from python, I get the error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/shared/Builds/Python-3.10.0/lib/python3.10/ssl.py", line 98, in <module> import _ssl # if we can't import it, let the error propagate ModuleNotFoundError: No module named '_ssl'
I can't find _ssl.so in build or install directory.
Thanks -S _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/IIFABHN7... Code of Conduct: http://python.org/psf/codeofconduct/
![](https://secure.gravatar.com/avatar/6ad1811de8100dc2f561d597023c8542.jpg?s=120&d=mm&r=g)
On 18/10/2021 18:50, Senthil Kumaran wrote:
Your configure script did pick up openssl as the support version was not found.
What is your operating system? Make sure you have supported version of ssl. Python requires openssl 1.1.1 or higher.
....... I tried to build this on ubuntu 18.04, but got the _ssl problem; it definitely has openssl 1.1.1 installed. On updated Arch linux no issue. during configure I see that compiling and linking against openssl works. with the simplest ./configure --prefix=$HOME/LOCAL/3.10.0 I find _ssl is not importable (_socket is). If I try setting --with-openssl-rpath I get _ssl importable, but it fails because _socket is not importable. It's not a big deal as I can install python 3.10.0 using deadsnakes-ubuntu-ppa-bionic ppa. I think the problem here is that I don't seem to have a single openssl root /usr/lib/x86_64-linux-gnu/libssl.so.1.1 /usr/include/openssl/ This all used to work in Python 3.9.x, but I suppose some improvement(s) have been made. -- Robin Becker
![](https://secure.gravatar.com/avatar/33bd15feb2558d0050e863875e0f5f60.jpg?s=120&d=mm&r=g)
On 19/10/2021 11.57, Robin Becker wrote:
On 18/10/2021 18:50, Senthil Kumaran wrote:
Your configure script did pick up openssl as the support version was not found.
What is your operating system? Make sure you have supported version of ssl. Python requires openssl 1.1.1 or higher.
....... I tried to build this on ubuntu 18.04, but got the _ssl problem; it definitely has openssl 1.1.1 installed. On updated Arch linux no issue.
during configure I see that compiling and linking against openssl works.
with the simplest ./configure --prefix=$HOME/LOCAL/3.10.0 I find _ssl is not importable (_socket is).
If I try setting --with-openssl-rpath I get _ssl importable, but it fails because _socket is not importable.
It's not a big deal as I can install python 3.10.0 using deadsnakes-ubuntu-ppa-bionic ppa.
I think the problem here is that I don't seem to have a single openssl root
/usr/lib/x86_64-linux-gnu/libssl.so.1.1 /usr/include/openssl/
This all used to work in Python 3.9.x, but I suppose some improvement(s) have been made.
For PEP 644 I added new instructions how to build Python 3.10 with custom OpenSSL builds. The instructions should work on all major Linux distributions. They have been tested on Debian-like and Fedora-like platforms: https://docs.python.org/3/using/unix.html?highlight=openssl#custom-openssl
![](https://secure.gravatar.com/avatar/6ad1811de8100dc2f561d597023c8542.jpg?s=120&d=mm&r=g)
On 19/10/2021 11:21, Christian Heimes wrote:
On 19/10/2021 11.57, Robin Becker wrote: .......... For PEP 644 I added new instructions how to build Python 3.10 with custom OpenSSL builds. The instructions should work on all major Linux distributions. They have been tested on Debian-like and Fedora-like platforms:
https://docs.python.org/3/using/unix.html?highlight=openssl#custom-openssl
Unfortunately I don't have a custom openssl installation although it may not appear/behave as the python configuration wants. I am using the officially approved installed version of openssl so far as I know. I'm aware that Ubuntu 18.04 is now somewhat out of date, but I would expect a simple configure & make dance to succeed. I'm working with linux for dummies(self) and need to install/update/upgrade openssl, libssl-dev. After that _ssl _hashlib are compiled and importable. I suppose the configure 'compiling with openssl' test is a bit naive. -- Robin Becker
![](https://secure.gravatar.com/avatar/33bd15feb2558d0050e863875e0f5f60.jpg?s=120&d=mm&r=g)
On 19/10/2021 17.26, Robin Becker wrote:
On 19/10/2021 11:21, Christian Heimes wrote:
On 19/10/2021 11.57, Robin Becker wrote: .......... For PEP 644 I added new instructions how to build Python 3.10 with custom OpenSSL builds. The instructions should work on all major Linux distributions. They have been tested on Debian-like and Fedora-like platforms:
https://docs.python.org/3/using/unix.html?highlight=openssl#custom-openssl
Unfortunately I don't have a custom openssl installation although it may not appear/behave as the python configuration wants.
I am using the officially approved installed version of openssl so far as I know. I'm aware that Ubuntu 18.04 is now somewhat out of date, but I would expect a simple configure & make dance to succeed.
I'm working with linux for dummies(self) and need to install/update/upgrade openssl, libssl-dev. After that _ssl _hashlib are compiled and importable. I suppose the configure 'compiling with openssl' test is a bit naive.
We use the standard AX_CHECK_OPENSSL() m4 macro from autoconf-archive to detect OpenSSL. The macro uses pkg-config to detect OpenSSL. It doesn't check for specific version, though. We don't want to prevent people with outdated OpenSSL or LibreSSL from building Python without ssl support. Christian
![](https://secure.gravatar.com/avatar/6ad1811de8100dc2f561d597023c8542.jpg?s=120&d=mm&r=g)
On 19/10/2021 16:45, Christian Heimes wrote:
We use the standard AX_CHECK_OPENSSL() m4 macro from autoconf-archive to detect OpenSSL. The macro uses pkg-config to detect OpenSSL. It doesn't check for specific version, though. We don't want to prevent people with outdated OpenSSL or LibreSSL from building Python without ssl support.
Christian I would not suggest that, but if the test at the end of the configure had said it can compile against openssl, but that a wrong or insufficient information would prevent building _ssl then a lot of cycles could be saved.
I suppose that might be impossible as the test might need to actually try and build _ssl.so. -- Robin Becker
![](https://secure.gravatar.com/avatar/33bd15feb2558d0050e863875e0f5f60.jpg?s=120&d=mm&r=g)
On 20/10/2021 09.43, Robin Becker wrote:
On 19/10/2021 16:45, Christian Heimes wrote:
We use the standard AX_CHECK_OPENSSL() m4 macro from autoconf-archive to detect OpenSSL. The macro uses pkg-config to detect OpenSSL. It doesn't check for specific version, though. We don't want to prevent people with outdated OpenSSL or LibreSSL from building Python without ssl support.
Christian I would not suggest that, but if the test at the end of the configure had said it can compile against openssl, but that a wrong or insufficient information would prevent building _ssl then a lot of cycles could be saved.
I suppose that might be impossible as the test might need to actually try and build _ssl.so.
That's an excellent idea! I can add an autoconf test that checks the most important and newish API. The check won't catch all problems, but it will detect most common cases of missing APIs in headers and libraries. PR: https://github.com/python/cpython/pull/29088 Christian
![](https://secure.gravatar.com/avatar/19f86070fe66228c89d7bdce2df82dbb.jpg?s=120&d=mm&r=g)
Christian Heimes wrote:
For PEP 644 I added new instructions how to build Python 3.10 with custom OpenSSL builds. The instructions should work on all major Linux distributions. They have been tested on Debian-like and Fedora-like platforms: https://docs.python.org/3/using/unix.html?highlight=openssl#custom-openssl
CentOS Linux release 7.9.2009 (Core) trying to build python 3.10.4 I followed the instructions at https://docs.python.org/3/using/unix.html?highlight=openssl#custom-openssl and cannot import ssl in the resulting build. My log of what I did follows. Struggling with this for a couple of days, so any help would be appreciated. 2022-05-24 11:24 sudo find /etc/ -name openssl.cnf -printf "%h\n" /etc/pki/tls 2022-05-24 11:27 cd /home/lking/openssl/openssl-1.1.1o 2022-05-24 11:27 sudo ./config --prefix=/usr/local/custom-openssl --libdir=lib --openssldir=/etc/pki/tls 2022-05-24 11:28 sudo make clean 2022-05-24 11:29 sudo make -j1 depend 2022-05-24 11:29 sudo make -j > logs/build1.txt 2022-05-24 11:32 sudo make install_sw > logs/install_sw.txt 2022-05-24 11:33 cd /home/lking/python/Python-3.10.4 2022-05-24 11:34 ./configure -C --with-openssl=/usr/local/custom-openssl --with-openssl-rpath=auto --prefix=/usr/local/python-3.10.4 > logs/configure4.txt 2022-05-23 11:35 vim /home/lking/python/Python-3.10.4/Makefile # https://stackoverflow.com/a/50855855/799921 199c199 < RUNSHARED= --- > RUNSHARED=LD_LIBRARY_PATH=/usr/local/custom-openssl/lib 2022-05-24 11:37 sudo make clean 2022-05-24 11:38 sudo make -j > logs/buildlog4.txt 2022-05-24 11:42 sudo make altinstall > logs/altinstall4.txt 2022-05-24 11:43 [lking@loutility-server-digitalocean Python-3.10.4]$ python3.10 Python 3.10.4 (main, May 15 2022, 12:44:05) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux Type "help", "copyright", "credits" or "license" for more information.
import ssl Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.10/ssl.py", line 98, in <module> import _ssl # if we can't import it, let the error propagate ModuleNotFoundError: No module named '_ssl'
![](https://secure.gravatar.com/avatar/19f86070fe66228c89d7bdce2df82dbb.jpg?s=120&d=mm&r=g)
I should have mentioned, earlier I made these changes to Setup 2022-05-22 14:54 vim /home/lking/python/Python-3.10.4/Modules/Setup 207c207 < #_socket socketmodule.c --- > _socket socketmodule.c 211,217c211,217 < # OPENSSL=/path/to/openssl/directory < # _ssl _ssl.c \ < # -I$(OPENSSL)/include -L$(OPENSSL)/lib \ < # -lssl -lcrypto < #_hashlib _hashopenssl.c \ < # -I$(OPENSSL)/include -L$(OPENSSL)/lib \ < # -lcrypto --- > OPENSSL=/usr/local/custom-openssl > _ssl _ssl.c \ > -I$(OPENSSL)/include -L$(OPENSSL)/lib \ > -lssl -lcrypto > _hashlib _hashopenssl.c \ > -I$(OPENSSL)/include -L$(OPENSSL)/lib \ > -lcrypto
![](https://secure.gravatar.com/avatar/05d87ca318b05167fba68148d974b070.jpg?s=120&d=mm&r=g)
Besides, producing the best online assignment help and bespoke scholastic research papers for every academic stream, We guarantee you the best academic grades for each of your assignments. Our confidence lies in the profoundly qualified and highly experienced subject experts we have on our panel. https://www.greatassignmenthelper.com/nz/
![](https://secure.gravatar.com/avatar/19f86070fe66228c89d7bdce2df82dbb.jpg?s=120&d=mm&r=g)
It turns out the one problem was being caused by the manual change to Makefile I made at 2022-05-23 11:35. My build goes through now by prefixing after LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/custom-openssl/lib after sudo, as the root account was not getting this environment variable. Having said that, while the dynamic load library now gets built correctly (it wasn't with the Makefile change), I still see the same symptom. Will continue to debug. I now see $ ls /usr/local/python-3.10.4/lib/python3.10/lib-dynload/*_ssl* /usr/local/python-3.10.4/lib/python3.10/lib-dynload/_ssl.cpython-310-x86_64-linux-gnu.so but still see $ python3.10 Python 3.10.4 (main, May 15 2022, 12:44:05) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux Type "help", "copyright", "credits" or "license" for more information.
import ssl Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.10/ssl.py", line 98, in <module> import _ssl # if we can't import it, let the error propagate ModuleNotFoundError: No module named '_ssl'
![](https://secure.gravatar.com/avatar/19f86070fe66228c89d7bdce2df82dbb.jpg?s=120&d=mm&r=g)
Solved! The astute reader will notice that while I built the latest version of python3.10 2022-05-24 11:38, the one I was testing was built May 15 2022, 12:44:05. This was left over from an earlier iteration, and not cleaned up with a subsequent make clean that was run after another ./configure with a different --prefix value.
participants (6)
-
Christian Heimes
-
Lou King
-
Robin Becker
-
Sandeep Gupta
-
scott tucker
-
Senthil Kumaran