Building Python 3.7 from source runs into following error:
Failed to build these modules:
_hashlib _ssl
Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381
I tried so many workarounds from other stackoverflow-questions, but it doesnt work. I build newest OpenSSL and LibreSSL from source. OpenSSL path is: "/usr/local/ssl" with version OpenSSL 1.0.2p.
./configure --with-openssl=/usr/local/ssl/
(./configure CPPFLAGS="-I/usr/local/ssl/include" LDFLAGS="-L/usr/local/ssl/lib")
make
make altinstall
My system: Ubuntu 12.04.5 LTS
Any ideas?
I solved it after 3 days only because of this blog. with python 3.7.4 openssl 1.1.0 centOS 6.
here is the summary :
First, some prerequisites:
use yum instead of apt-get if using centos linux.
Install ssl 1.0.2 or higher.
We will need to pass /usr/src/openssl-1.0.2o into the Python configure script.
Now proceed with installing Python:
To test it out, run python3.7 and input:
Hope it helps!
While this might not be the best answer, I will share how I solved this problem.
First of all, in my case, OpenSSL did not build correctly, as
make test
did return errors (and consequently Python gave this error). This was solved by installing a newer version of Perl and then installing OpenSSL again (configure, make, etc).Use this command before using ./configure
At the configure command, include the library:
as apparently the option for configure does not convey the message to the C compiler which needs it.
Am not sure whether option 2 and 3 are needed simultaneously, but I did so and it worked.
Compiling openssl
sudo mv openssl-1.0.2u /usr/local/openssl && cd /usr/local/openssl
sudo make distclean
sudo ./config -fPIC -shared
sudo make && sudo install
vim ~/.profile Go export PATH="/usr/local/openssl/lib:$PATH" :wq
Compiling Python3
sudo make distclean
vim /{yourpythonsource}/Modules/Setup
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/openssl _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto
sudo ./configure --with-openssl=/usr/local --prefix=/opt/python-3.7.1
sudo make && sudo make install
Edit
setup.py
Find the following lines:
...and place each folder at the beginning of its respective list.
In my case I had to add:
/usr/local/lib
and/usr/local/include
:Finally:
make distclean && ./configure
You may want to ensure that
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
(or what have you) is added to the very end of/etc/profile
and reboot, as well.Here is a solution on Mac OS X / Homebrew:
Then download your python tarball and do this:
More detai: