Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib? #950

Closed
jingle0927 opened this issue Jul 17, 2017 · 73 comments
Closed

Comments

@jingle0927
Copy link

@jingle0927 jingle0927 commented Jul 17, 2017

➜ ~ pyenv install 3.5.2
Installing Python-3.5.2...
patching file Lib/venv/scripts/posix/activate.fish
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems

BUILD FAILED (Deepin 15.4 using python-build 20160602)

Inspect or clean up the working tree at /tmp/python-build.20170717074120.10900
Results logged to /tmp/python-build.20170717074120.10900.log

Last 10 log lines:
(cd /home/zonzely/.pyenv/versions/3.5.2/share/man/man1; ln -s python3.5.1 python3.1)
if test "xupgrade" != "xno" ; then
case upgrade in
upgrade) ensurepip="--upgrade" ;;
install|*) ensurepip="" ;;
esac;
./python -E -m ensurepip
$ensurepip --root=/ ;
fi
Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS

@aitk
Copy link

@aitk aitk commented Jul 19, 2017

What os and version are you using ?

Also the fix is right there in the message you will need to go to https://github.com/pyenv/pyenv/wiki/Common-build-problems#error-the-python-ssl-extension-was-not-compiled-missing-the-openssl-lib then just copy and paste the script for your specific os

@elderone
Copy link

@elderone elderone commented Aug 7, 2017

Debian GNU/Linux 9.1 (stretch)
pyenv 1.1.3
CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib pyenv install -v 3.2.3

ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (Debian 9.1 using python-build 20160602)

Inspect or clean up the working tree at /tmp/python-build.20170807132419.25380
Results logged to /tmp/python-build.20170807132419.25380.log

Last 10 log lines:
rm -f /home/elderone/.pyenv/versions/3.2.3/bin/python3-config
(cd /home/elderone/.pyenv/versions/3.2.3/bin; ln -s python3.2-config python3-config)
rm -f /home/elderone/.pyenv/versions/3.2.3/lib/pkgconfig/python3.pc
(cd /home/elderone/.pyenv/versions/3.2.3/lib/pkgconfig; ln -s python-3.2.pc python3.pc)
rm -f /home/elderone/.pyenv/versions/3.2.3/bin/idle3
(cd /home/elderone/.pyenv/versions/3.2.3/bin; ln -s idle3.2 idle3)
rm -f /home/elderone/.pyenv/versions/3.2.3/bin/pydoc3
(cd /home/elderone/.pyenv/versions/3.2.3/bin; ln -s pydoc3.2 pydoc3)
rm -f /home/elderone/.pyenv/versions/3.2.3/bin/2to3
(cd /home/elderone/.pyenv/versions/3.2.3/bin; ln -s 2to3-3.2 2to3)
@elderone
Copy link

@elderone elderone commented Aug 7, 2017

building '_ssl' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/openssl -I/home/elderone/.pyenv/versions/3.2.3/include -fPIC -IInclude -I. -I./Include -I/home/elderone/.pyenv/versions/3.2.3/include
 -I/usr/include/x86_64-linux-gnu -I/usr/local/include -I/tmp/python-build.20170807132419.25380/Python-3.2.3 -c /tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c -o build/temp.linux-x86_64-3.2/tm
p/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.o
In file included from Include/Python.h:111:0,
                 from /tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c:17:
Include/modsupport.h:27:1: warning: ‘PyArg_ParseTuple’ is an unrecognized format function type [-Wformat=]
 PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3);
 ^~~~~~~~~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c: In function ‘_create_tuple_for_X509_NAME’:
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c:487:35: error: dereferencing pointer to incomplete type ‘X509_NAME_ENTRY {aka struct X509_name_entry_st}’
             if (rdn_level != entry->set) {
                                   ^~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c: In function ‘_get_peer_alt_names’:
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c:607:16: error: dereferencing pointer to incomplete type ‘X509_EXTENSION {aka struct X509_extension_st}’
         p = ext->value->data;
                ^~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c: In function ‘PySSL_cipher’:
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c:960:21: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     cipher_protocol = SSL_CIPHER_get_version(current);
                     ^
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c: In function ‘context_new’:
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c:1458:9: warning: ‘TLSv1_method’ is deprecated [-Wdeprecated-declarations]
         ctx = SSL_CTX_new(TLSv1_method());
         ^~~
In file included from /usr/include/openssl/ct.h:13:0,
                 from /usr/include/openssl/ssl.h:61,
                 from /tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c:93:
/usr/include/openssl/ssl.h:1612:1: note: declared here
 DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_method(void)) /* TLSv1.0 */
 ^
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c:1465:27: warning: implicit declaration of function ‘SSLv2_method’ [-Wimplicit-function-declaration]
         ctx = SSL_CTX_new(SSLv2_method());
                           ^~~~~~~~~~~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c:1465:27: warning: passing argument 1 of ‘SSL_CTX_new’ makes pointer from integer without a cast [-Wint-conversion]
In file included from /tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c:93:0:
/usr/include/openssl/ssl.h:1321:17: note: expected ‘const SSL_METHOD * {aka const struct ssl_method_st *}’ but argument is of type ‘int’
 __owur SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);
                 ^~~~~~~~~~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c: In function ‘PySSL_RAND_egd’:
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c:1924:13: warning: implicit declaration of function ‘RAND_egd’ [-Wimplicit-function-declaration]
     bytes = RAND_egd(PyBytes_AsString(path));
             ^~~~~~~~
At top level:
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c:1974:13: warning: ‘_ssl_thread_locking_function’ defined but not used [-Wunused-function]
 static void _ssl_thread_locking_function
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_ssl.c:1970:22: warning: ‘_ssl_thread_id_function’ defined but not used [-Wunused-function]
 static unsigned long _ssl_thread_id_function (void) {
                      ^~~~~~~~~~~~~~~~~~~~~~~
building '_hashlib' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/openssl -I/home/elderone/.pyenv/versions/3.2.3/include -fPIC -IInclude -I. -I./Include -I/home/elderone/.pyenv/versions/3.2.3/include
 -I/usr/include/x86_64-linux-gnu -I/usr/local/include -I/tmp/python-build.20170807132419.25380/Python-3.2.3 -c /tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c -o build/temp.linux-x86_6
4-3.2/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.o
In file included from Include/Python.h:111:0,
                 from /tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:16:
Include/modsupport.h:27:1: warning: ‘_PyArg_ParseTuple_SizeT’ is an unrecognized format function type [-Wformat=]
 PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3);
 ^~~~~~~~~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:62:26: error: field ‘ctx’ has incomplete type
     EVP_MD_CTX           ctx;   /* OpenSSL message digest context */
                          ^~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c: In function ‘EVP_dealloc’:
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:129:5: warning: implicit declaration of function ‘EVP_MD_CTX_cleanup’ [-Wimplicit-function-declaration]
     EVP_MD_CTX_cleanup(&self->ctx);
     ^~~~~~~~~~~~~~~~~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c: In function ‘EVP_digest’:
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:165:16: error: storage size of ‘temp_ctx’ isn’t known
     EVP_MD_CTX temp_ctx;
                ^~~~~~~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:165:16: warning: unused variable ‘temp_ctx’ [-Wunused-variable]
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c: In function ‘EVP_hexdigest’:
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:185:16: error: storage size of ‘temp_ctx’ isn’t known
     EVP_MD_CTX temp_ctx;
                ^~~~~~~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:185:16: warning: unused variable ‘temp_ctx’ [-Wunused-variable]
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c: At top level:
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:74:23: error: storage size of ‘CONST_new_md5_ctx’ isn’t known
     static EVP_MD_CTX CONST_new_ ## Name ## _ctx; \
                       ^
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:77:1: note: in expansion of macro ‘DEFINE_CONSTS_FOR_NEW’
 DEFINE_CONSTS_FOR_NEW(md5)
 ^~~~~~~~~~~~~~~~~~~~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:74:23: error: storage size of ‘CONST_new_sha1_ctx’ isn’t known
     static EVP_MD_CTX CONST_new_ ## Name ## _ctx; \
                       ^
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:78:1: note: in expansion of macro ‘DEFINE_CONSTS_FOR_NEW’
 DEFINE_CONSTS_FOR_NEW(sha1)
 ^~~~~~~~~~~~~~~~~~~~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:74:23: error: storage size of ‘CONST_new_sha224_ctx’ isn’t known
     static EVP_MD_CTX CONST_new_ ## Name ## _ctx; \
                       ^
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:80:1: note: in expansion of macro ‘DEFINE_CONSTS_FOR_NEW’
 DEFINE_CONSTS_FOR_NEW(sha224)
 ^~~~~~~~~~~~~~~~~~~~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:74:23: error: storage size of ‘CONST_new_sha256_ctx’ isn’t known
     static EVP_MD_CTX CONST_new_ ## Name ## _ctx; \
                       ^
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:81:1: note: in expansion of macro ‘DEFINE_CONSTS_FOR_NEW’
 DEFINE_CONSTS_FOR_NEW(sha256)
 ^~~~~~~~~~~~~~~~~~~~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:74:23: error: storage size of ‘CONST_new_sha384_ctx’ isn’t known
     static EVP_MD_CTX CONST_new_ ## Name ## _ctx; \
                       ^
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:82:1: note: in expansion of macro ‘DEFINE_CONSTS_FOR_NEW’
 DEFINE_CONSTS_FOR_NEW(sha384)
 ^~~~~~~~~~~~~~~~~~~~~
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:74:23: error: storage size of ‘CONST_new_sha512_ctx’ isn’t known
     static EVP_MD_CTX CONST_new_ ## Name ## _ctx; \
                       ^
/tmp/python-build.20170807132419.25380/Python-3.2.3/Modules/_hashopenssl.c:83:1: note: in expansion of macro ‘DEFINE_CONSTS_FOR_NEW’
 DEFINE_CONSTS_FOR_NEW(sha512)
 ^~~~~~~~~~~~~~~~~~~~~

Python build finished, but the necessary bits to build these modules were not found:
_dbm               _gdbm                              
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


Failed to build these modules:
_hashlib           _ssl                               

@elderone
Copy link

@elderone elderone commented Aug 8, 2017

CFLAGS="-I/usr/include/x86_64-linux-gnu/" LDFLAGS="-L/usr/lib/x86_64-linux-gnu/" PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.2.3
all the same...

@bosr
Copy link

@bosr bosr commented Aug 28, 2017

Hi, look at #945, it's because Debian 9 uses OpenSSL 1.1.0 which support in CPython was added in 3.5.3 (more details in the issue above). Cheers

@dstyp
Copy link

@dstyp dstyp commented Sep 8, 2017

No solution to this yet? Trying to install...

@bosr
Copy link

@bosr bosr commented Sep 8, 2017

@dstyp, are you trying to install a version < 3.5.3? If so I don't know, else the above answers (CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib pyenv install -v 3.5.3) should work.

@dstyp
Copy link

@dstyp dstyp commented Sep 8, 2017

Worked! Thanks, completely overlooked your comment.

@tirtaabimanyu
Copy link

@tirtaabimanyu tirtaabimanyu commented Sep 21, 2017

+1 having same trouble installing 3.5.2 on ubuntu

@makslevental
Copy link

@makslevental makslevental commented Sep 29, 2017

i'm having this on mac os high sierra even with setting CFLAGS and LDFLAGS correctly using brew --prefix

@uber1geek
Copy link

@uber1geek uber1geek commented Sep 29, 2017

@makslevental Same here.

Is there a fix available for HighSierra ?

@makslevental
Copy link

@makslevental makslevental commented Sep 29, 2017

@uber1geek the problem turned out to be the openssl hadn't actually successfully installed (even though homebrew reported that it had). run brew uninstall openssl && brew install openssl && CFLAGS="-I$(brew --prefix openssl)/include" LDFLAGS="-L$(brew --prefix openssl)/lib" pyenv install 3.6.2

@colllin
Copy link

@colllin colllin commented Sep 29, 2017

I'm using macOS / OSX, but not homebrew, and I'm having this issue as well.

Is there a way to determine...

  1. whether I have openssl installed?

    I tried...

    $ which openssl
    /usr/bin/openssl
    
  2. the correct CFLAGS / LDFLAGS?

    I tried...

    $ CFLAGS="-I/usr/bin/openssl" LDFLAGS="-L/usr/lib" pyenv install 3.6.2
    Downloading readline-6.3.tar.gz...
    -> https://pyenv.github.io/pythons/56ba6071b9462f980c5a72ab0023893b65ba6debb4eeb475d7a563dc65cafd43
    Installing readline-6.3...
    Installed readline-6.3 to /Users/colllin/.pyenv/versions/3.6.2
    
    Downloading Python-3.6.2.tar.xz...
    -> https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
    Installing Python-3.6.2...
    ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
    
    Please consult to the Wiki page to fix the problem.
    https://github.com/pyenv/pyenv/wiki/Common-build-problems
    
    
    BUILD FAILED (OS X 10.13 using python-build 20160602)
    
    Inspect or clean up the working tree at /var/folders/95/rsx7725n60vf4gjk0g9_1h_w0000gn/T/python-build.20170929153257.78102
    Results logged to /var/folders/95/rsx7725n60vf4gjk0g9_1h_w0000gn/T/python-build.20170929153257.78102.log
    
    Last 10 log lines:
    			upgrade) ensurepip="--upgrade" ;; \
    			install|*) ensurepip="" ;; \
    		esac; \
    		 ./python.exe -E -m ensurepip \
    			$ensurepip --root=/ ; \
    	fi
    Collecting setuptools
    Collecting pip
    Installing collected packages: setuptools, pip
    Successfully installed pip-9.0.1 setuptools-28.8.0
    
@makslevental
Copy link

@makslevental makslevental commented Sep 29, 2017

@colllin you need the openssl headers which are in the include dir. i don't know where yours would be

@laenderoliveira
Copy link

@laenderoliveira laenderoliveira commented Oct 4, 2017

I found a solution to my problem. (Fedora 26)
Uninstall:
$ dnf remove openssl-devel

Install:
$ dnf install compat-openssl10-devel

@jlott
Copy link

@jlott jlott commented Oct 5, 2017

Mac OS X 10.13 (High Sierra) uses LibreSSL 2.2.7 but doesnt include the C headers necessary to compile the SSL extension for python. I know of no Apple-provided method to get them installed (via XCode or whatever else). To get this working without homebrew or any other shenanigans (assuming you have pyenv installed and working properly);

  • curl -O https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.2.7.tar.gz
  • tar xvf libressl-2.2.7.tar.gz
  • CFLAGS="-I./libressl-2.2.7/include" pyenv install 3.6.3 (or whatever other version)

(post edit)
I believe that pyenv is supposed to install openssl as necessary on Mac OS X in order to make the whole pyenv install process work properly. That is probably the real issue here, but the above steps appear to work around the problem for now.

@matheusabr
Copy link

@matheusabr matheusabr commented Oct 11, 2017

I tried all suggestions above but it is not working on Hight Sierra 10.13.1 Beta (17B25c) and Xcode 9

@crazyxrp
Copy link

@crazyxrp crazyxrp commented Oct 12, 2017

@matheusabr I use @makslevental's method and it works
os version 10.13
installed python version 3.5.4

@matheusabr
Copy link

@matheusabr matheusabr commented Oct 13, 2017

@crazyxrp It really works! Thanks

@tranvansang
Copy link

@tranvansang tranvansang commented Oct 16, 2017

install openssl-devel.x86_64 or (openssl-dev...) should work.

openssl package only is not enough

Source: https://stackoverflow.com/questions/6171210/building-python-and-more-on-missing-modules

@iartarisi
Copy link

@iartarisi iartarisi commented Oct 20, 2017

On Debian stretch, installing libssl1.0-dev (and removing libssl-dev) with apt worked fine. Python 2.7 installs fine now.

@jonatanvianna
Copy link

@jonatanvianna jonatanvianna commented Dec 1, 2017

@laenderoliveira
woked for me

I found a solution to my problem. (Fedora 26)
Uninstall:
$ dnf remove openssl-devel
Install:
$ dnf install compat-openssl10-devel

@Beenhakker
Copy link

@Beenhakker Beenhakker commented Dec 4, 2017

In my case (Homebrew, OSX 10.13.1 - High Sierra) I had to specify both CFLAGS and CPPFLAGS:
LDFLAGS="-L/usr/local/opt/openssl/lib" CPPFLAGS="-I/usr/local/opt/openssl/include" CFLAGS="-I/usr/local/opt/openssl/include" pyenv install 3.6.3

@robrem
Copy link

@robrem robrem commented Dec 14, 2017

@Beenhakker
Your method worked for me in OSX 10.13.1 for installing 3.6.3. Thanks!

@justinjdickow
Copy link

@justinjdickow justinjdickow commented Dec 31, 2017

Not working for me to install 2.7.14 :(

@awper361
Copy link

@awper361 awper361 commented Jan 5, 2018

Not working for me to install 2.7.6

@Adzz
Copy link

@Adzz Adzz commented Jan 13, 2020

On MacOs 10.15.2 there seems to be literally nothing I can do to get it working.

Have tried re-installing openssl, tried setting compiler flags, tried complete nuclear uninstall python using brew and not brew.

CFLAGS="-I$(brew --prefix openssl)/include" LDFLAGS="-L$(brew --prefix openssl)/lib" asdf install python 3.5.2
python-build 3.5.2 /Users/adamlancaster/.asdf/installs/python/3.5.2
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.5.2.tar.xz...
-> https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
Installing Python-3.5.2...
patching file Lib/venv/scripts/posix/activate.fish
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (OS X 10.15.2 using python-build 1.2.16-2-g36fc10fb)

Inspect or clean up the working tree at /var/folders/gm/84m52gh16sx9g7l_gln_w77r0000gn/T/python-build.20200113113216.50262
Results logged to /var/folders/gm/84m52gh16sx9g7l_gln_w77r0000gn/T/python-build.20200113113216.50262.log

Last 10 log lines:
(cd /Users/adamlancaster/.asdf/installs/python/3.5.2/share/man/man1; ln -s python3.5.1 python3.1)
if test "xupgrade" != "xno"  ; then \
		case upgrade in \
			upgrade) ensurepip="--upgrade" ;; \
			install|*) ensurepip="" ;; \
		esac; \
		 ./python.exe -E -m ensurepip \
			$ensurepip --root=/ ; \
	fi
Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS
@robbydyer
Copy link

@robbydyer robbydyer commented Jan 17, 2020

I believe the issue here is that python <= 3.5.2 needs openssl 1.0. Homebrew removed openssl 1.0 recently (Homebrew/homebrew-core#46454). I suspect installing anything v3.5.3 or greater will work, but anything older than that won't compile with openssl 1.1.

@afrancht
Copy link

@afrancht afrancht commented Jan 20, 2020

@robbydyer @Adzz Did you find a solution for MacOS Catalina (10.15)?

@Adzz
Copy link

@Adzz Adzz commented Jan 20, 2020

@afrancht What worked for me was: brew uninstall --ignore-dependencies openssl then installing python. In my case I was using asdf, but I think python will install its own version of openssl if you do that.

@edarioq
Copy link

@edarioq edarioq commented Jan 26, 2020

@afrancht What worked for me was: brew uninstall --ignore-dependencies openssl then installing python. In my case I was using asdf, but I think python will install its own version of openssl if you do that.

This works, it seems it downloads the version of SSL that it needs by itself. Thanks.

@tik0
Copy link

@tik0 tik0 commented Feb 4, 2020

Debian GNU/Linux 9.1 (stretch)
pyenv 1.1.3
CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib pyenv install -v 3.2.3

ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (Debian 9.1 using python-build 20160602)

Inspect or clean up the working tree at /tmp/python-build.20170807132419.25380
Results logged to /tmp/python-build.20170807132419.25380.log

Last 10 log lines:
rm -f /home/elderone/.pyenv/versions/3.2.3/bin/python3-config
(cd /home/elderone/.pyenv/versions/3.2.3/bin; ln -s python3.2-config python3-config)
rm -f /home/elderone/.pyenv/versions/3.2.3/lib/pkgconfig/python3.pc
(cd /home/elderone/.pyenv/versions/3.2.3/lib/pkgconfig; ln -s python-3.2.pc python3.pc)
rm -f /home/elderone/.pyenv/versions/3.2.3/bin/idle3
(cd /home/elderone/.pyenv/versions/3.2.3/bin; ln -s idle3.2 idle3)
rm -f /home/elderone/.pyenv/versions/3.2.3/bin/pydoc3
(cd /home/elderone/.pyenv/versions/3.2.3/bin; ln -s pydoc3.2 pydoc3)
rm -f /home/elderone/.pyenv/versions/3.2.3/bin/2to3
(cd /home/elderone/.pyenv/versions/3.2.3/bin; ln -s 2to3-3.2 2to3)

It is easier to let the system choose the proper directories for openssl under debian/ubuntu. This worked for me after install all Prerequisites:

CFLAGS=$(pkg-config openssl --cflags-only-I) LDFLAGS=$(pkg-config openssl --libs-only-L) pyenv install -v 3.6.1

@mcstrassell09
Copy link

@mcstrassell09 mcstrassell09 commented Mar 21, 2020

I follwed the directions from Pyenv Wiki meticulously several times. Still, THIS DOES NOT WORK. Support, ideas, or condolences are accepted.

I reset my ENV with

% PATH=$(getconf PATH)

THen clean up my ~/.zshrc file. Currently, Looks like this:

PATH="~/.pyenv/shims:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH

export PYENV_ROOT="$HOME/.pyenv"
export TMPDIR="$HOME/src"


if type brew &>/dev/null; then
  FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH

  autoload -Uz compinit
  compinit
fi

eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

Then reset my shell with

source ~/.zshrc

Next I installed pyenv doctor with

$ git clone git://github.com/pyenv/pyenv-doctor.git $(pyenv root)/plugins/pyenv-doctor

and ran with varying results

$ pyenv doctor ....

Cloning into ~/.pyenv/plugins/pyenv-doctor/bin/.....
Installing python-pyenv-doctor...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 10.15.3 using python-build 20180424)

Inspect or clean up the working tree at ~/src/python-build.20200321133544.93124
Results logged to /Users/mark/src/python-build.20200321133544.93124.log

Deleted temp builds from ~/src (That I specified in ~/.zshrc) and re-ran

$ pyenv doctor ...

BUILD FAILED (OS X 10.15.3 using python-build 20180424)

Inspect or clean up the working tree at /Users/mark/src/python-build.20200321133803.94231
Results logged to /Users/mark/src/python-build.20200321133803.94231.log

Last 10 log lines:
checking readline/readline.h, usability... no
checking readline/readline.h, presence... no
checking for readline/readline.h,... no
checking readline/rlconf.h usability... yes
checking readline/rlconf.h presence... yes
checking for readline/rlconf.h... yes
checking for SSL_library_init in -lssl... no
configure: WARNING: OpenSSL <1.1 not installed. Checking v1.1 or beyond...
checking for OPENSSL_init_ssl in -lssl... no
configure: error: OpenSSL is not installed.

Next I added the flags as listed in the pyenv wiki

$ CFLAGS="-I$(brew --prefix openssl@1.1)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" CPPFLAGS="-I$(brew --prefix zlib)/include -I$(brew --prefix openssl@1.1)/include" LDFLAGS="-L$(brew --prefix openssl@1.1)/lib -L$(brew --prefix readline)/lib" pyenv doctor

...

Installed python-pyenv-doctor to ~/src/pyenv-doctor.20200321134239.97399/prefix

Congratulations! You are ready to build pythons!

Great! It pyenv doctor worked! Now I uses the same flags to install python 2.7.7

$ CFLAGS="-I$(brew --prefix openssl@1.1)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" CPPFLAGS="-I$(brew --prefix zlib)/include -I$(brew --prefix openssl@1.1)/include" LDFLAGS="-L$(brew --prefix openssl@1.1)/lib -L$(brew --prefix readline)/lib" pyenv install -v 2.7.7

...

ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (OS X 10.15.3 using python-build 20180424)

Inspect or clean up the working tree at ~/src/python-build.20200321134415.99281
Results logged to ~/src/python-build.20200321134415.99281.log

EPIC FAIL! Inpsecting the log I found some notables:

ld: framework not found QuickTime
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Python build finished, but the necessary bits to build these modules were not found:
_bsddb             bsddb185           dl              
imageop            linuxaudiodev      ossaudiodev     
spwd               sunaudiodev                        
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


Failed to build these modules:
_hashlib           _Qt                _ssl 

#Please Help, any expert advice would be much obliged!!

@ypankovych

This comment has been minimized.

@jyoo
Copy link

@jyoo jyoo commented Apr 19, 2020

@dstyp, are you trying to install a version < 3.5.3? If so I don't know, else the above answers (CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib pyenv install -v 3.5.3) should work.

This is still valid!
Python: 3.8.0
OS: OSX Catalina
Using 3.8.0, and encountered the below when I tried to pip install ...

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/

I found that when I did python on Terminal, I could not import ssl:

import ssl
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/james/.pyenv/versions/3.8.0/lib/python3.8/ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: dlopen(/Users/james/.pyenv/versions/3.8.0/lib/python3.8/lib-dynload/_ssl.cpython-38-darwin.so, 2): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /Users/james/.pyenv/versions/3.8.0/lib/python3.8/lib-dynload/_ssl.cpython-38-darwin.so
  Reason: image not found

By doing CFLAGS=-I/usr/include/openssl LDFLAGS=-L/usr/lib pyenv install -v 3.8.0, I now can do pip install

@uguryilmazunified
Copy link

@uguryilmazunified uguryilmazunified commented Apr 26, 2020

Removing ssl from brew via brew uninstall --ignore-dependencies openssl@1.1
and pyenv install -v 3.4.1 worked for me

@asmith-r7
Copy link

@asmith-r7 asmith-r7 commented Apr 27, 2020

Removing ssl from brew via brew uninstall --ignore-dependencies openssl@1.1
and pyenv install -v 3.4.1 worked for me

Also worked for me. I did have other libraries which depend on 1.1 so I just reinstalled it after getting python installed.

Is this something which could be added to pyenv to ignore openssl 1.1 for version of python which don't support it?

@ahmadaking
Copy link

@ahmadaking ahmadaking commented Apr 28, 2020

my system is macOs 10.14.6
i tried :
$ pyenv install 2.7.10

bu get an error :

python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-2.7.10.tar.xz...
-> https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
Installing Python-2.7.10...
patching file ./Lib/site.py
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems

### BUILD FAILED (OS X 10.14.6 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/0g/gmp473xj3wg9v9cmw2ngl0l80000gn/T/python-build.20200428151934.51752
Results logged to /var/folders/0g/gmp473xj3wg9v9cmw2ngl0l80000gn/T/python-build.20200428151934.51752.log

Last 10 log lines:
rm -f /Users/ahmadsamir/.pyenv/versions/2.7.10/share/man/man1/python.1
(cd /Users/ahmadsamir/.pyenv/versions/2.7.10/share/man/man1; ln -s python2.1 python.1)
if test "xno" != "xno" ; then
case no in
upgrade) ensurepip="--upgrade" ;;
install|*) ensurepip="" ;;
esac;
./python.exe -E -m ensurepip
$ensurepip --root=/ ;
fi

@robbydyer
Copy link

@robbydyer robbydyer commented May 5, 2020

To summarize the "fix" for folks on Mac OSX needing any version of python < 3.5.1.

Steps are:

  • Uninstall openssl@1.1, since you cannot compile python versions prior to 3.5.1 with openssl 1.1. Homebrew removed openssl@1.0, so you can't install it anymore
  • Install your python version (using 2.7.16 as example here)
  • Reinstall openssl@1.1
brew uninstall --force --ignore-dependencies openssl@1.1 && \
pyenv install -v 2.7.16 && \
brew install openssl@1.1
@asmith-r7
Copy link

@asmith-r7 asmith-r7 commented May 5, 2020

I found a much nicer way (could have been on this thread or elsewhere) which means you don't need to uninstall openssl. There is an environment variable you can use to specify which open ssl to use. I was able to use the following to install 3.4.4. Hope that helps someone.

PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl@1.0 pyenv install 3.4.4

@jsnb
Copy link

@jsnb jsnb commented May 11, 2020

I found a much nicer way (could have been on this thread or elsewhere) which means you don't need to uninstall openssl. There is an environment variable you can use to specify which open ssl to use. I was able to use the following to install 3.4.4. Hope that helps someone.

PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl@1.0 pyenv install 3.4.4

+1 for this 🎉 @asmith-r7

Uninstall and reinstalling openssl worked for 3.5.2 but not 3.4.4.

@softprops
Copy link

@softprops softprops commented May 16, 2020

The closest I've got is #950 (comment)

My issue is that that pip never gets installed. A python without pip is not that useful if you need dependencies.

The tail end of my output indicates an permissions issue with an directory /lib which seems like an odd directory I'm used to something more like /usr/lib

if test "xno" != "xno"  ; then \
                case no in \
                        upgrade) ensurepip="--upgrade" ;; \
                        install|*) ensurepip="" ;; \
                esac; \
                 ./python.exe -E -m ensurepip \
                        $ensurepip --root=/ ; \
        fi
Installing pip from https://bootstrap.pypa.io/get-pip.py...
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting pip
  Using cached pip-20.1-py2.py3-none-any.whl (1.5 MB)
Collecting setuptools
  Using cached setuptools-44.1.0-py2.py3-none-any.whl (583 kB)
Collecting wheel
  Using cached wheel-0.34.2-py2.py3-none-any.whl (26 kB)
Installing collected packages: pip, setuptools, wheel
ERROR: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: '/lib'

I'm on osx catalina 10.15.4

brew --version
Homebrew 2.2.16-69-g9fcaa46
Homebrew/homebrew-core (git revision ed660b; last commit 2020-05-16)
Homebrew/homebrew-cask (git revision cc821; last commit 2020-05-16)
@jpchavat
Copy link

@jpchavat jpchavat commented Jul 8, 2020

To install python 2.6.x. in MacOS Catalina I mixed two posted solutions in the thread. What follows is the result that worked for me:

brew install --force https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb
CFLAGS="-I$/usr/local/Cellar/openssl/1.0.2t/include"
LDFLAGS="-L$/usr/local/Cellar/openssl/1.0.2t/lib"

brew uninstall --force --ignore-dependencies openssl@1.1
pyenv install -v 2.6.6
/Users/<user>/.pyenv/versions/2.6.6/bin/python <-- Now is installed and works!
brew install openssl

I hope it works for you. 💪

@terrisgit
Copy link

@terrisgit terrisgit commented Jul 22, 2020

Here is how I build a specific version of Python3 on macOS 10.14.6 Mojave with support for enchant (spell check) and Sphinx with PDF generation.

#!/bin/sh
set -e

# Install XCode command-line tools
xcode-select --install
pkgutil --pkg-info=com.apple.pkg.CLTools_Executables

# Install zlib
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

# Install Brew (comment out if you already have it)
mkdir brew
cd brew
curl -O https://raw.githubusercontent.com/Homebrew/install/master/install
ruby install
rm install
cd ..
rmdir brew

# Upgrade brew
brew update

# Needed for Imagemagick
sudo mkdir /usr/local/Frameworks
sudo chown $(whoami):admin /usr/local/Frameworks

# Install Imagemagick and TeX for Sphinx PDF generation
# Install enchant for spell check linting
# Install pyenv
brew cask install mactex
brew cask upgrade mactex
brew install homebrew/core/make pyenv imagemagick enchant
brew upgrade homebrew/core/make pyenv imagemagick enchant

# Install python3 using pyenv
export PYVERSION=3.7.7
PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl@1.0 SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk MACOSX_DEPLOYMENT_TARGET=10.14 pyenv install $PYVERSION
pyenv rehash
@whyisyoung
Copy link

@whyisyoung whyisyoung commented Aug 10, 2020

Support for OpenSSL 1.1.x, was only added in Python 2.7.13, 3.5.3 and 3.6.0.

Found this and finally give up installing Python 2.7.11 and switch to Python 2.7.13 because I have OpenSSL 1.1.1g installed.

But pyenv install 2.7.13 still does not work, I had to use wget -P $(pyenv root)/cache https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz before pyenv install 2.7.13

Finally it works. By the way, I'm using Cent OS 7 and the error is ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

@jicowan
Copy link

@jicowan jicowan commented Sep 3, 2020

make: *** [install] Error 1

BUILD FAILED (OS X 10.15.6 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/8x/0pb59h191rx0z98hv748n5b93m2scn/T/python-build.20200903142101.80200
Results logged to /var/folders/8x/0pb59h191rx0z98hv748n5b93m2scn/T/python-build.20200903142101.80200.log

Last 10 log lines:
		 ./python.exe -E -m ensurepip \
			$ensurepip --root=/ ; \
	fi
Looking in links: /var/folders/8x/0pb59h191rx0z98hv748n5b93m2scn/T/tmp5emg3txn
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
ERROR: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: '/lib'

make: *** [install] Error 1

I can't get this to work on MacOS 10.15.6 either. This is the command I used to install 3.7.5:

CFLAGS="-I/usr/local/opt/openssl@1.1/include" LDFLAGS="-L/usr/local/opt/openssl@1.1/lib" pyenv install -v 3.7.5

@anentropic
Copy link

@anentropic anentropic commented Sep 30, 2020

Same problem... Ubuntu 14.04 and Python 3.8.6

still trying to find the right incantation to make it work

apt-get install libssl-dev did not help

@anentropic
Copy link

@anentropic anentropic commented Sep 30, 2020

issue seems to be around OpenSSL / libssl-dev version

under Ubuntu 14.04 after doing apt-get update && apt-get install libssl-dev I see:

Step 3/18 : RUN openssl version -a
 ---> Running in 6c1258406a98
OpenSSL 1.0.1f 6 Jan 2014

and the Python 3.8.6 install fails with the error from this issue

Upgrading the container to Ubuntu 18 gives:

Step 3/18 : RUN openssl version -a
 ---> Running in dd26ca4d216f
OpenSSL 1.1.1  11 Sep 2018

and the Python install succeeds

@brianz
Copy link

@brianz brianz commented Oct 13, 2020

I found a much nicer way (could have been on this thread or elsewhere) which means you don't need to uninstall openssl. There is an environment variable you can use to specify which open ssl to use. I was able to use the following to install 3.4.4. Hope that helps someone.

PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl@1.0 pyenv install 3.4.4

Very helpful! I was able to use this method to install 2.7.18 on macOS 10.15.7:

PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl@1.0 pyenv install  2.7.18
@hpl002
Copy link

@hpl002 hpl002 commented Jan 21, 2021

I found a much nicer way (could have been on this thread or elsewhere) which means you don't need to uninstall openssl. There is an environment variable you can use to specify which open ssl to use. I was able to use the following to install 3.4.4. Hope that helps someone.
PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl@1.0 pyenv install 3.4.4

Very helpful! I was able to use this method to install 2.7.18 on macOS 10.15.7:

PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl@1.0 pyenv install  2.7.18

also had success with this on osx 10.15.6

@sabotagebeats
Copy link

@sabotagebeats sabotagebeats commented Apr 13, 2021

ubuntu 20 LTS running on WSL2 windows 10

sudo apt-get update && sudo apt-get install libssl-dev

now I'm able to install python 3.8.9 with pyenv

@BigSully
Copy link

@BigSully BigSully commented Apr 21, 2021

Issue resolved on my debian 9 after I installed the required packages specified in https://github.com/pyenv/pyenv/wiki/Common-build-problems#prerequisites

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet