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

Trying to use Python 3.6 on Ubuntu 16.04:

Execute installation script
##[debug]Check if Python hostedtoolcache folder exist...
##[debug]Deleting Python 3.6.10
##[debug]Create Python 3.6.10 folder
##[debug]Copy Python binaries to hostedtoolcache folder
##[debug]Create additional symlinks (Required for UsePythonVersion VSTS task)
##[debug]Upgrading PIP...
##[debug]Looking in links: /tmp/tmp5xjr9lqz
##[debug]Requirement already satisfied: setuptools in /opt/hostedtoolcache/Python/3.6.10/x64/lib/python3.6/site-packages (40.6.2)
##[debug]Requirement already satisfied: pip in /opt/hostedtoolcache/Python/3.6.10/x64/lib/python3.6/site-packages (18.1)
##[debug]Collecting pip
##[debug]Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
##[debug]Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
##[error]The process '/bin/bash' failed with exit code 1
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Set up Python

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 9
  • Comments: 46 (4 by maintainers)

Most upvoted comments

resolved.

  1. first install openssl, please refer to this page
  2. install python and ./configure --with-openssl=/home/username/openssl
  3. at last, run python3 -m ssl and nothing outputs, it’s ok.

If any body still facing issue Follow these steps install openssl with /home/username

set export PATH=$HOME/openssl/bin:$PATH export LD_LIBRARY_PATH=/home/username/openssl/lib export LC_ALL=“en_US.UTF-8” export LDFLAGS=“-L/home/username/openssl/lib -Wl,-rpath,/home/username/openssl/lib” export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/home/username/openssl/lib/

execute in Python folder ./configure -prefix=/home/username/Python38/ --with-openssl=/home/username/openssl make make install python3 -m ssl

The solution used here (https://bugs.python.org/issue34028#msg339455) helped me:

  1. I installed openssl with the default prefix (to /usr/local)
  2. Then I needed to set LD_LIBRARY_PATH: export LD_LIBRARY_PATH=$LD_LIBARY_PATH:/usr/local/lib64:/usr/local/lib
  3. Afterwards, so that python configuration succeeds, I needed to set LD_FLAGS: export LDFLAGS="-L/usr/local/lib -L/usr/local/lib64 -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/local/lib64"
  4. Finally, after configuring with ./configure --with-openssl=/usr/local/ and installing with make && make install python3 -m ssl worked

resolved.

  1. first install openssl, please refer to this page
  2. install python and ./configure --with-openssl=/home/username/openssl
  3. at last, run python3 -m ssl and nothing outputs, it’s ok.

thanks, resolved.

Hi all,

A bit of fudging with this answer solved my problem. (Plus using virtual env.)

Nothing worked for me until I yum installed openssl-devel and bzip2-devel before building python on CentOS. Neither LD manipulation nor setting --with-openssl while configuring the build was necessary. The names of those packages for apt would be libssl-dev and libbz2-dev, but I have not tried it.

I managed to include SSL library with

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/home/username/openssl/lib/

before step ./configure --with-openssl=/home/username/openssl

now python3 -m ssl give no errors

On Ubuntu (tested on 22.04) it is sufficient to install libssl-dev and then rerun configure. There is no need to install a local openssl.

If re-running configure on a machine that already has the required libs is all that’s needed, can that be added to setup-python? I feel like almost none of the comments are focusing on the actual Action we are supposedly trying to use.

hello @utapyngo

With the fact that self-hosted environment must have openssl libraries installed and with the solution provided @chasays i believe the issue can be closed. But please feel free to reopen this issue or create another one in case if the problem still exists.

Thanks a lot for all these answers. For me, I also found that it also worked even after I removed the openssl installed in my home directory and cancel export LD_LIBRARY_PATH for it’s lib. So I just tried many other times for digging into it. And I summarize as follows:

Firstly. I installed openssl in my home directory and set its related LD_LIBRARY_PATH before I installed python3.9 from source code with ./configure --with-openssl={openssl path I just installed manually}. And ./pip3 install worked without any SSL error.

Afterwards, I removed the openssl and unset the environment variable for it, but still no SSL error when I use ./pip3 to install packages.

Another time, I remove all the things mentioned above and install openssl again. This time I didn’t set its LD_LIBRARY_PATH and only set --with-openssl={openssl path I just installed manually} and then install python3.9 before I removed openssl again. So there is no manually installed openssl any more. Still, it worked.

In conclusion, I guess the procedure of ‘configure’ python3.9 needs an openssl directory and only needs for ‘configure’, for some reason it cannot find one (I mean it cannot find the default openssl the system already has). So just install and set one explicitly. After configuring, making and installing python, it is of no use for normally running python and pip.

I encountered this problem on one of my lab servers (labeled as 1), but everything went well on another (labeled as 0). I cannot find where is different between them since both default openssl are on /usr (but for 1 is on /usr/local/bin and for 0 on /usr/bin).

resolved.

1. first install openssl, please refer to [this page](https://help.dreamhost.com/hc/en-us/articles/360001435926-Installing-OpenSSL-locally-under-your-username)

2. install python and `./configure --with-openssl=/home/username/openssl`

3. at last, run `python3 -m ssl` and nothing outputs, it's ok.

I install ssl and use same command , last command not working “python3 -m ssl” , same problem not resolved

Got this working for installing Python 3.11.2 on Amazon Linux 2. (An OS Similar to CentOS 7/Rhel 7) I had to install a different openssl version, which Amazon Repo’s provide. You can still leave the regular openssl rpm installed, but you must REMOVE openssl-devel if installed. The three packages you must install AFTER REMOVING openssl-devel are:

  • openssl11-1.1.1g
  • openssl11-libs-1.1.1g
  • openssl11-devel-1.1.1g

Once installed just run ./configure --enable-optimizations (no need for the --with-openssl as the configure script already has a defined locations to look for your openssl, you only need to provide it if your openssl is not within those standard directories, you can find the locations in the script)

Do not let the g fool you, amazon updates their RPM’s without changing the letter at the end, so yes it’s patched for vulnerabilities.

Reference: https://alas.aws.amazon.com/AL2/ALAS-2023-1934.html

Hope this helps!

Also some more info if interested:

Everytime you run ./configure it creates a config.log. I saw it was finding my original openssl in the config.log, however, it was not happy with the version I was using, and the capabilities of that version based on some tests it would do. Which is what led me to find out there was a different openssl Amazon provided in which python3.11.2 was happy with.

On Ubuntu (tested on 22.04) it is sufficient to install libssl-dev and then rerun configure. There is no need to install a local openssl.

I have the problem to not be able to find the bash_profile

I am using Kali Linux on VMWare, and it copied the vmware iso (not the installer, i don’t know if there is a difference)

I did all others steps but I am guessing the change in the bash_profile is mandatory, unfortunately i cant do it

Can someone help ?

try . ~/.profile instead

or editing bashrc

https://askubuntu.com/questions/510709/i-cannot-find-bash-profile-in-ubuntu

resolved.

  1. first install openssl, please refer to this page
  2. install python and ./configure --with-openssl=/home/username/openssl
  3. at last, run python3 -m ssl and nothing outputs, it’s ok.

I was able to get a version of python built to use a openssl in a home directory, however the setup-python doesn’t seem to ever want to use that version. Even setting up the python and python3 symlink in /usr/bin still result it in trying to install its own version and failing. Any advice on how to force setup-python to use a specific python binary?

@EvanPHamilton, that’s what I did, and it helped. The problem is that the environment variables must be set individually for every Python version because the Github Actions runner does not work with openssl1.1.