Search code examples
pythonlinuxopensusepyenv

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


I have tried installing Python in pyenv env, but I am getting the error below. I have added openssl to the path variable as openssl is already available, but still it is throwing the same error.

Also, I tried with a separate user (not root). Same error! And I tried to follow the wiki page (https://github.com/pyenv/pyenv/wiki/Common-build-problems#error-the-python-ssl-extension-was-not-compiled-missing-the-openssl-lib), but for OpenSUSE I can't find much help on google too.

Can someone guide me on how to proceed this further?

xxxxx@xxxxxxxxxxx:~/.pyenv> pyenv install 3.5.2
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...
    WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
    WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
    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 (SLES 12.1 using python-build 20160726)
    
    Inspect or clean up the working tree at /tmp/python-build.20160801100205.31144
    Results logged to /tmp/python-build.20160801100205.31144.log
    
    Last 10 log lines:
    (cd /home/xxxxx/.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

Solution

  • Python makes use of underlying operating system libraries to support some of its libraries, and it appears you don't have these libraries installed. On Ubuntu you should be able to install them with

    $ sudo apt-get install bzip2 libreadline6 libreadline6-dev openssl
    

    For SUSE 12, as you have pointed out, the command required was

    zypper -n install openssl libopenssl-devel
    

    EDIT Sep 30, 2023: Note, however, that unless you are creating virtual images it's poor practice to install required functionality into the system Python. Instead, use it (or a different Python version you've installed yourself) to create a virtual environment, and install the necessary dependencies in there. That way you aren't cluttering up other projects' environment with unnecessary (and possibly conflicting) dependencies.