Python SSL module unavailable when installing package with pip3

I installed Python 3.4 and Python 3.6 on my local computer successfully, but cannot install packages with pip3 .

When I execute pip3 install <package> , I get the following SSL related error :

 pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. Collecting <package> Could not fetch URL https://pypi.python.org/simple/<package>/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping Could not find a version that satisfies the requirement <package> (from versions: ) No matching distribution found for <package> 

How can I fix my Python3.x installation to install packages using pip install <package> ?

+48
source share
15 answers

Python 3.6 and pip3 installation walkthrough on Ubuntu

  1. Install the necessary packages for Python and ssl: $ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

  2. Download and unzip "Python-3.6.8.tar.xz" from https://www.python.org/ftp/python/ into your home directory.

  3. Open a terminal in this directory and run: $./configure

  4. Assembly and installation: $ sudo make && sudo make install

  5. Install packages using: $ pip3 install package_name

+56
source

If you are on Red Hat / CentOS:

 # To allow for building python ssl libs yum install openssl-devel # Download the source of *any* python version cd /usr/src wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz tar xf Python-3.6.2.tar.xz cd Python-3.6.2 # Configure the build w/ your installed libraries ./configure # Install into /usr/local/bin/python3.6, don't overwrite global python bin make altinstall 
+45
source

If you use Windows and use Anaconda, this works for me:

I tried many other solutions that did not work (PATH environment variable ...)

The problem can be caused by DLL files in the Windows \ System32 folder (for example, libcrypto-1_1-x64.dll or libssl-1_1-x64.dll or others) hosted by other software.

The fix installed openSSL from https://slproweb.com/products/Win32OpenSSL.html, which replaces libraries with later versions.

+19
source

I agree with the answer from mastaBlasta. Worked for me. I ran into the same problem as the topic description.

Environment: MacOS Sierra. And I use Homebrew.

My decision:

  1. Reinstall openssl with brew uninstall openssl, brew install openssl ;
  2. Follow the recommendations of Homebrew to do the following:

    echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

    export LDFLAGS="-L/usr/local/opt/openssl/lib"

    export CPPFLAGS="-I/usr/local/opt/openssl/include"

+9
source

On Ubuntu, this can help:

 cd Python-3.6.2 ./configure --with-ssl make sudo make install 
+7
source

The problem is probably caused by the lack of a library.

Before installing python 3.6, make sure you have installed all the libraries necessary for python.

 $ sudo apt-get install build-essential checkinstall $ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev 

More information in How to install Python 3.6.0 on Ubuntu and LinuxMint

+6
source

I ran into the same issue on Windows 10. My very specific issue is related to my Anaconda installation. I installed Anaconda and along the Path/to/Anaconda3/ path, python.exe appears there. So I did not install python at all, because Anaconda includes python. When using pip to install packages, I found the same error report, pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. ,

The solution was as follows:

1) you can download python again on the official website ;

2) Go to the directory where "Python 3.7 (64-bit).lnk"

3) import ssl and exit()

4) enter cmd, for example, "Python 3.7 (64-bit).lnk" -m pip install tensorflow , "Python 3.7 (64-bit).lnk" -m pip install tensorflow .

Everything is ready here.

+5
source

If you are on OSX and compiled python from source:

Install openssl with brew brew install openssl

Be sure to follow the brew instructions to configure CPPFLAGS and LDFLAGS . In my case, I use the openssl@1.1 brew formula, and I need these 3 parameters for the python build process to correctly reference my SSL library:

 export LDFLAGS="-L/usr/local/opt/ openssl@1.1 /lib" export CPPFLAGS="-I/usr/local/opt/ openssl@1.1 /include" export PKG_CONFIG_PATH="/usr/local/opt/ openssl@1.1 /lib/pkgconfig" 

Suppose the library is installed at this location.

+4
source

If you are on Windows and using Anaconda, you can try running the “install item ...” in Anaconda. Tell me instead of cmd.exe, as the user willliu1995 offers here . For me it was the fastest solution that did not require the installation of additional components.

+2
source

I had the same problem and managed to solve it using the following steps:

 sudo yum install -y libffi-devel sudo yum install openssl-devel cd /usr/src sudo wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz sudo tar xf Python-3.7.1.tar.xz cd Python-3.7.1 sudo ./configure --enable-optimizations # Install into /usr/local/bin/python3.7, don't overwrite global python bin sudo make altinstall 

you may not need sudo depending on the perm.

 Results: Collecting setuptools Collecting pip Installing collected packages: setuptools, pip Successfully installed pip-10.0.1 setuptools-39.0.1 

should now be able to run

 python3.7 -V 

and

 pip3.7 -V 

When installing packages:

 pip3.7 install pandas 

or, depending on the permissions, you can also add the --user flag as follows:

 pip3.7 install pandas --user 
+1
source

I had the same problem in the last two days, and I fixed it right now.

I tried to use the --trust-host parameter with DigiCert_High_Assurance_EV_Root_CA.pem , it didn’t work, I could not install the ssl module (it says that it cannot be installed for python versions greater than 2.6), setting the variable $PIP_CERT also didn’t fix it, and I installed libssl1.0.2 and libssl1.0.0 . It is also worth mentioning that I did not have the ~/.pip/pip.conf , and creating it also did not solve the error.

Which finally decided, installed python3.6 again with make . Download Python-3.6.0.tgz from the website, run configure , then make , make test and make install . Hope this works for you.

0
source

I had the same problem when trying to install python3.7 on a machine with Ubuntu14.04. The problem was that I had several user folders in my PKG_CONFIG_PATH and in my LD_LIBRARY_PATH, which prevented the Python build process from finding openssl system libraries.

so try cleaning them and see what happens:

 export PKG_CONFIG_PATH="" export LD_LIBRARY_PATH="" 
0
source

Can someone help me with the same issue, but for Microsoft Windows?

I'm having trouble finding a solution for windows here.

0
source

I tried MANY ways to solve this problem, and none solved. I am currently on Windows 10.

The only thing that worked was:

  • Remove Anaconda
  • Remove Python (I used version 3.7.3)
  • Install Python again (do not forget to check the option to automatically add to PATH)

Then I downloaded all the necessary libraries using PIP ... and it works!

I don’t know why, or the problem was somehow connected with Anaconda.

0
source

The Python documentation is actually very clear, and following the instructions did its job, while the other answers I found here did not solve this problem.

  1. First install Python 3.xx from the source code, using, for example, version 3.6.2 https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz

  2. make sure you have openssl installed by running brew install openssl

  3. unzip it and go to the python directory: tar xvzf Python-3.6.2.tar.xz && cd Python-3.6.2

  4. then if the version of Python is <3.7, run

CPPFLAGS="-I$(brew --prefix openssl)/include"\LDFLAGS="-L$(brew --prefix openssl)/lib"\./configure --with-pydebug 5. CPPFLAGS="-I$(brew --prefix openssl)/include"\LDFLAGS="-L$(brew --prefix openssl)/lib"\./configure --with-pydebug , run make -s -j2 ( -s is the silence flag, -j2 tells your machine to use 2 jobs)

-1
source

Source: https://habr.com/ru/post/1261897/


All Articles