skip to Main Content

I’m on Ubuntu 22.04.1 which comes whit its own python3.11, where pip works perfectly.
If I install other python versions through apt-get (sudo apt-get install python3.10) the related pip works perfectly.

But I just installed an alternative python version (3.7.9 ) from source (I’m not able to use apt for this python version), doing the following

cd usr/lib
sudo wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
sudo tar xzf Python-3.7.9.tg
cd Python-3.7.9
sudo ./configure --enable-optimizations
sudo make altinstall

Python3.7 works fine, but if I try to install any package (using pip3.7 or, after creating a virtualenv based on python3.7, using pip) I get the following warning

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

Followed by the error

ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
ERROR: No matching distribution found for numpy 

I’m sure I have Openssl installed because other versions of python don’t give probelms with pip (also I can see ssl in the folder /etc/ssl) so the problem seems to be related only on a link between ssl and python installed from source.

Any suggestions?

2

Answers


  1. Chosen as BEST ANSWER

    If it can help anyone, I found a solution: before doing

    sudo ./configure --enable-optimizations
    sudo make altinstall
    

    I simply modified part of the file Modules/Setup.dist

    from

    # Socket module helper for SSL support; you must comment out the other
    # socket line above, and possibly edit the SSL variable:
    #SSL=/usr/local/ssl
    # _ssl _ssl.c 
    #    -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl 
    #    -L$(SSL)/lib -lssl -lcrypto
    

    to

    # Socket module helper for SSL support; you must comment out the other
    # socket line above, and possibly edit the SSL variable:
    SSL=/etc/ssl
    _ssl _ssl.c 
        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl 
        -L$(SSL)/lib -lssl -lcrypto
    

    Notice that /etc/ssl is the actual location where I have ssl installed.

    After the file modification I than installed with

    sudo ./configure --enable-optimizations
    sudo make altinstall
    

    And now (after eventually upgrading pip and setuptools) pip works fine.


  2. For Python 3.11.1 on Ubuntu 22.04.1, you do not need to modify any distribution files, just add --with-openssl-rpath=/usr/lib/x86_64-linux-gnu to the ./configure command line.

    The ssl & crypto libs are in that directory, and this ensures they’re located at runtime

    Note this assumes you’re running on an x86_64 distro, I expect there’s a similar directory on ARM.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search