Pyenv: 3.2 installation fails with SSL error

Created on 22 May 2013  ·  23Comments  ·  Source: pyenv/pyenv

pyenv install command fails when installing 3.2 but succeeds with 3.2.5 and 3.1.5:

ubuntu@box144:~$ pyenv install 3.1.5
Downloading Python-3.1.5.tgz...
-> http://www.python.org/ftp/python/3.1.5/Python-3.1.5.tgz
Installing Python-3.1.5...
Installed Python-3.1.5 to /home/ubuntu/.pyenv/versions/3.1.5

Downloading distribute-0.6.40.tar.gz... [...]
Downloading pip-1.3.1.tar.gz... [...]

ubuntu@box144:~$ pyenv install 3.2.5
Downloading Python-3.2.5.tgz...
-> http://yyuu.github.io/pythons/ed8d5529d2aebc36b53f4e0a0c9e6728
Installing Python-3.2.5...
Installed Python-3.2.5 to /home/ubuntu/.pyenv/versions/3.2.5

Downloading distribute-0.6.40.tar.gz... [...]
Downloading pip-1.3.1.tar.gz... [...]

ubuntu@box144:~$ pyenv install 3.2
Downloading Python-3.2.tgz...
-> http://yyuu.github.io/pythons/5efe838a7878b170f6728d7e5d7517af
Installing Python-3.2...

BUILD FAILED

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

Last 10 log lines:
  File "<string>", line 2, in <module>
  File "/home/ubuntu/.pyenv/versions/3.2/lib/python3.2/ssl.py", line 60, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: No module named _ssl

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 4, in <module>
ImportError: The Python ssl extension was not compiled. Missing the OpenSSL lib?
bug

Most helpful comment

Suggest looking into this ticket once more, was unable to install new pythons with homebrew installed openssl.

Ran into exact same problem and found this ticket:

$ brew upgrade pyenv
Error: pyenv-20140211 already installed
$ pyenv install 2.7.4
....
BUILD FAILED

Inspect or clean up the working tree at /var/folders/3y/7jrv6jr95fnbs9rr0vx1xwzc0000gn/T/python-build.20140212160358.97455
Results logged to /var/folders/3y/7jrv6jr95fnbs9rr0vx1xwzc0000gn/T/python-build.20140212160358.97455.log

Last 10 log lines:
  File "<string>", line 1, in <module>
  File "/Users/doug/.pyenv/versions/2.7.4/lib/python2.7/ssl.py", line 60, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: No module named _ssl

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

What worked for me:

$ CFLAGS="-I$(brew --prefix openssl)/include" \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
pyenv install 2.7.4

All 23 comments

This might be a build problem of ssl module with recent version of OpenSSL. I added patch in SHA@5fbc3ae3d5629081507b691a3549007cff1cffc6 to prevent this error.

@notnoop
Please try rebuilding with latest master.

@notnoop
Aren't you there?

I close this since I've confirmed that the build problem has been fixed on my machine.

I have the same problem. It's not yet fixed.
I tried installing openssl via homebrew but the problem persists.

@Rnhmjoj
Which version of Python did you met openssl problem with? Please show me the actual output of pyenv install --verbose ${version} as gist.

@yyuu The version is version: 3.3.2. Here is the log.

@Rnhmjoj
hmm... looks somewhat strange :(

The build problem of ssl module of CPython 3.3.2 must be another problem. The problem on CPython 3.2 was caused by the recent changes in OpenSSL (it drops support for SSLv2).

https://github.com/yyuu/pyenv/blob/master/plugins/python-build/share/python-build/patches/3.2/Python-3.2/001_openssl_no_ssl2.patch

Though, CPython 3.3.2 is quite new and equivalent fix has been applied by default, this must not be a problem.

For more investigation, I'd like to have another issue for your problem.

Suggest looking into this ticket once more, was unable to install new pythons with homebrew installed openssl.

Ran into exact same problem and found this ticket:

$ brew upgrade pyenv
Error: pyenv-20140211 already installed
$ pyenv install 2.7.4
....
BUILD FAILED

Inspect or clean up the working tree at /var/folders/3y/7jrv6jr95fnbs9rr0vx1xwzc0000gn/T/python-build.20140212160358.97455
Results logged to /var/folders/3y/7jrv6jr95fnbs9rr0vx1xwzc0000gn/T/python-build.20140212160358.97455.log

Last 10 log lines:
  File "<string>", line 1, in <module>
  File "/Users/doug/.pyenv/versions/2.7.4/lib/python2.7/ssl.py", line 60, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: No module named _ssl

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

What worked for me:

$ CFLAGS="-I$(brew --prefix openssl)/include" \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
pyenv install 2.7.4

So I updated the 2.7.6 file with the changes in #22 and I still get the same error as the most recent comment from beck. Am I missing something simple. On MacOS Mavericks.
just running "pyenv install 2.7.6"

@yina in the end I had to ditch the homebrew openssl.
What ended up working for me:

brew uninstall openssl
brew upgrade pyenv
pyenv install 2.7.6

thanks beck. I should clarify that I am using macports for which openssl is installed. I do have the latest pyenv with "pyenv update" with the changes I made to the 2.7.6 file.

This recent commit looks as though openssl will be included if not available, so I would try sudo port uninstall openssl. And if openssl is needed for other projects, use what is delivered with xcode. Hope this helps

@beck @yina
The commit 6b0710e263ee92a4ae15822e38b1037775d93609 has not been merged into master. I wonder if I should merge it since I can build CPython 2.7.6 with linking against OS X's default OpenSSL 0.9.8 on OS X Mavericks.

Please let me know further information:

  1. Do you have Command Line Tools for Xcode installed?
  2. What is your default C compiler? You can check it with which cc; cc -v
  3. The environment variables of CFLAGS, LDFLAGS and CPPFLAGS
  4. The output from pyenv install -v 2.7.6 2>&1 | tee build.log

@yyuu after your few comments I looked more closely about my build environment, dumb me didn't specify the LDFLAGS and CPPFLAGS correctly so it wasn't working. I updated the LDFLAGS and CPPFLAGS to

export LDFLAGS="-L/opt/local/lib" 
export CPPFLAGS="-I/opt/local/include"

and then ran

pyenv install -v 2.7.6

and it worked! thank you!

:tada:

:congratulations:

beck's fix also worked for me but I used brew's openssl
CFLAGS="-I$(brew --prefix openssl)/include" \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
pyenv install 2.7.4

In Yosemite 10.10.x and homebrew openssl 1.0.2d, I had to change the previous oneliner to:
LDFLAGS="-L$(brew --prefix openssl)/lib" CPPFLAGS="-I$(brew --prefix openssl)/include" pyenv install 2.7.10

It seems that now CPPFLAGS must be used instead of CFLAGS.

For me, I had to include LDFLAGS and CPPFLAGS for openssl, zlib and sqlite3.

The command to link zlib and openssl works for me: CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib" CPPFLAGS="-I$(brew --prefix openssl)/include" pyenv install -v 3.5.0

I just upgrade to El Capitan 10.11.

I'm also having this problem with ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

I am running a clean install of El Capitan 10.11 instead of an upgrade. I have tried all the solutions above, the same with the wiki troubleshooting and still get the same error.

Here is the full error (I can also put the full log in a gist if you'd like):

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/yyuu/pyenv/wiki/Common-build-problems


BUILD FAILED (OS X 10.11 using python-build 20150818)

Inspect or clean up the working tree at /var/folders/0f/z22q_whs0v30pr8lg6b_jfxr0000gn/T/python-build.20151003143338.30855
Results logged to /var/folders/0f/z22q_whs0v30pr8lg6b_jfxr0000gn/T/python-build.20151003143338.30855.log

Last 10 log lines:
rm -f /Users/gabo/.pyenv/versions/2.7.10/share/man/man1/python.1
(cd /Users/gabo/.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

Same error with clean El Capitan here:

Stefans-MBP:~ stefan$ pyenv install 3.4.3
Downloading readline-6.3.tar.gz...
-> https://yyuu.github.io/pythons/56ba6071b9462f980c5a72ab0023893b65ba6debb4eeb475d7a563dc65cafd43
Installing readline-6.3...
Installed readline-6.3 to /Users/stefan/.pyenv/versions/3.4.3

Downloading Python-3.4.3.tgz...
-> https://yyuu.github.io/pythons/4281ff86778db65892c05151d5de738d
Installing Python-3.4.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/yyuu/pyenv/wiki/Common-build-problems


BUILD FAILED (OS X 10.11 using python-build 20150818)

Inspect or clean up the working tree at /var/folders/v5/rk06g5z94txf2fglhrk9b3y40000gn/T/python-build.20151004141807.591
Results logged to /var/folders/v5/rk06g5z94txf2fglhrk9b3y40000gn/T/python-build.20151004141807.591.log

Last 10 log lines:
(cd /Users/stefan/.pyenv/versions/3.4.3/share/man/man1; ln -s python3.4.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 6.0.8 requires SSL/TLS

@MrLeeh It worked on El Capitan.

$ xcode-select --install
$ brew uninstall openssl
$ pyenv install 3.4.0

Downloading openssl-1.0.1p.tar.gz...
-> https://yyuu.github.io/pythons/bd5ee6803165c0fb60bbecbacacf244f1f90d2aa0d71353af610c29121e9b2f1
Installing openssl-1.0.1p...
Installed openssl-1.0.1p to /Users/CHANN/.pyenv/versions/3.4.0

Downloading Python-3.4.0.tgz...
-> https://yyuu.github.io/pythons/d2c83ea0217769a73e8b1ee33ffbca814903f8568e30f8d13e68e3d1f743449c
Installing Python-3.4.0...
Installed Python-3.4.0 to /Users/CHANN/.pyenv/versions/3.4.0

Nice! After trying everything else from the 'Common build problems' wiki, Issues #448 (although didn't try copperlight's exact command), #451, all with no success, the above solution from channprj worked for me. OS 10.11, El Capitan. Thanks!

$ brew uninstall openssl
$ brew uninstall --force openssl
$ pyenv install 2.7.10

Downloading openssl-1.0.1p.tar.gz...
-> https://yyuu.github.io/pythons/bd5ee6803165c0fb60bbecbacacf244f1f90d2aa0d71353af610c29121e9b2f1
Installing openssl-1.0.1p...
Installed openssl-1.0.1p to /Users/tylerarbour/.pyenv/versions/2.7.10

Downloading Python-2.7.10.tgz...
-> https://yyuu.github.io/pythons/eda8ce6eec03e74991abb5384170e7c65fcd7522e409b8e83d7e6372add0f12a
Installing Python-2.7.10...
patching file ./Lib/site.py
Installed Python-2.7.10 to /Users/tylerarbour/.pyenv/versions/2.7.10

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thedrow picture thedrow  ·  3Comments

demba picture demba  ·  3Comments

tasugi picture tasugi  ·  3Comments

ydaniju picture ydaniju  ·  3Comments

ipfans picture ipfans  ·  3Comments