Reputation: 2409
I've install Python 3.4 and Python 3.6 on my local machine successfully, but am unable to 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 install so that I can install packages with pip install <package>
?
Upvotes: 232
Views: 658991
Reputation: 13661
Step by step guide to install Python 3.6 and pip3 in Ubuntu
Install the necessary packages for Python and ssl: $ sudo apt-get install build-essential libffi-dev libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
Download and unzip "Python-3.6.8.tar.xz" from https://www.python.org/ftp/python/ into your home directory.
Open terminal in that directory and run: $ ./configure
Build and install: $ make && sudo make install
Install packages with: $ pip3 install package_name
Disclaimer: The above commands are not tested in Ubuntu 20.04 LTS.
Upvotes: 172
Reputation: 2751
When installing Python 3.11 on AWS Linux, you need to:
sudo yum remove openssl-devel
sudo yum install openssl11-1.1.1g openssl11-libs-1.1.1g openssl11-devel-1.1.1g
You can then just run:
./configure --enable-optimizations
sudo make altinstall
Answer from https://github.com/actions/setup-python/issues/93 and verified working as of January 2024
Upvotes: 1
Reputation: 81
I have this issue with centos 7 and python 3.6. None of the answers solves it and I finally figured out how to fix it.
First, install openssl from source code by following this link:
After that, ssl header file "openssl/ssl.h" is in path:
/usr/local/openssl/include
ssl lib file is in path;
/usr/local/openssl/lib
Now compile python from source code. Before compile it, go to setup.py
, locate function detect_modules()
, search for 'ssl'.
Add ssl include file path to the following code:
search_for_ssl_incs_in = [
'/usr/local/openssl/include'
]
For lib file, there is trick here.
the code is searching for ssl lib file firstly from some standard system paths:
lib_dirs: ['/usr/local/lib', '/lib64', '/usr/lib64', '/lib', '/usr/lib']
If any of these folder contains ssl lib file, then it will return an empty path so the compile will skip ssl. I don't know the logic here but I just removed ssl lib file from these paths. In my host, there is libssl.a
in /lib
, so move it to an subfolder.
Then assign ssl lib path in setup.py:
ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
[
'/usr/local/openssl/lib'
] )
Compile python:
./configure
make
make install
Upvotes: 0
Reputation: 1884
Building from source was what worked for me on Ubuntu 22.10:
Install OpenSSL manually, tested here with OpenSSL 1.1.1s, extracted then ran:
./config --prefix='/opt/openssl' --openssldir='/opt/ssl'
make
make install
Then with your older Python 3 version (here Python-3.8.16) run:
export LD_RUN_PATH='/opt/openssl/lib'
export CC='gcc-12' # sudo apt install gcc-12
./configure --enable-optimizations \
--with-openssl='/opt/openssl' \
--prefix='/opt/python/3.8' -C
make
make install
Test with:
/opt/python/3.8/bin/python3 -c 'import ssl; print(ssl.OPENSSL_VERSION)'
OpenSSL 1.1.1s 1 Nov 2022
Upvotes: 0
Reputation: 1949
I've made some PATH changes to mimic part of the Anaconda Powershell Prompt $env:PATH
C:\Users\merheb\Miniconda3;C:\Users\merheb\Miniconda3\Library\mingw-w64\bin;C:\Users\merheb\Miniconda3\Library\usr\bin;C:\Users\merheb\Miniconda3\Library\bin;C:\Users\merheb\Miniconda3\Scripts;C:\Users\merheb\Miniconda3\bin;C:\Users\merheb\Miniconda3\condabin;
And It worked for me.
Upvotes: 0
Reputation: 613
This worked because i didnt have an existing openssl version installed.
pkg install openssl-tool
Upvotes: 2
Reputation: 9
If in windows and using anaconda, than I solved it by first,
conda activate
pip install <lib>
This worked for me.
Upvotes: -5
Reputation: 351
I had the same issue with python3.8.5 installation on Debian9. I have done a build, but when I have tried to download some modules, pip3.8 issued following error:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
I have searched for the root of my problem and found out that there is a system dependent portion of the python build which is called by system independent one. In case of missing ssl you just needed to open python terminal and check whether is _ssl present:
>>> help('modules')
.
.
_sre enum pwd wave
_ssl errno py_compile weakref
_stat faulthandler pyclbr webbrowser
.
.
If not your system dependent ssl module part is missing. You can check it also by listing content of <python_installation_root>/lib/python3.8/lib-dynload:
>ls ./lib/python3.8/lib-dynload | grep ssl
_ssl.cpython-38-x86_64-linux-gnu.so
The problem was caused as written by PengShaw by missing libssl-dev during the build. Therefore you have to follow the recommended python installation flow. First install prerequisites and then build and install the python. Installation without devel versions of libs resulted in my case in the missing system dependent part. In this case _ssl.
Note that the devel lib name differs for Debian and CentOS, therefore check whether the installation hints posted on net are suitable for your specific Linux system type:
For Debian:
sudo apt install -y libbz2-dev libffi-dev libssl-dev
./configure --enable-optimizations
make
make altinstall
For CentOS:
sudo yum -y install bzip2-devel libffi-devel openssl-devel
./configure --enable-optimizations
make
make altinstall
It is for sure a good idea to list configuration options prior the configuration and evtl. use some additional options:
./configure --help
Last but not least in case you use --prefix for a non-default installation location, remember to add your <python_installation_root>/lib to your LD_LIBRARY_PATH .
Upvotes: 25
Reputation: 21
I was able to fix this by updating the python version in this file. pyenv: version `3.6.5' is not installed (set by /Users/taruntarun/.python-version) Though i had the latest version installed, my command was still using old version 3.6.5
Moving to version 3.7.3
Upvotes: 2
Reputation: 427
In the case of using pyenv
to manage python installations on Mac OS Catalina, I had to install openssl
with brew first and then after that run pyenv install 3.7.8
which seemed to build the python installation using the openssl
from homebrew (it even said as such in the installation output). Then pyenv global 3.7.8
and I was away.
Upvotes: 4
Reputation: 11
(NOT on Windows!)
This made me tear my hair out for a week, so I hope this will help someone
I tried everything short of re-installing Anaconda and/or Jupyter.
Setup
./anaconda3/bin/python
)/usr/bin/python
and /usr/bin/python3
(but these were not being used as most of the work was done in Jupyter's terminal)Fix
In Jupyter's terminal:
cp /usr/lib64/libssl.so.10 ./anaconda3/lib/libssl.so.1.0.0
cp /usr/lib64/libcrypto.so.10 ./anaconda3/lib/libcrypto.so.1.0.0
What triggered this?
So, this was all working until I tried to do a conda install conda-forge
I'm not sure what happened, but conda must have updated openssl
on the box (I'm guessing) so after this, everything broke.
Basically, unknown to me, conda had updated openssl, but somehow deleted the old libraries and replaced it with libssl.so.1.1
and libcrypto.so.1.1
.
Python3, I guess, was compiled to look for libssl.so.1.0.0
In the end, the key to diagnosis was this:
python -c "import ssl; print (ssl.OPENSSL_VERSION)"
gave the clue library "libssl.so.1.0.0" not found
The huge assumption I made is that the yum
version of ssl is the same as the conda
version, so just renaming the shared object might work, and it did.
My other solution was to re-compile python, re-install anaconda, etc, but in the end I'm glad I didn't need to.
Hope this helps you guys out.
Upvotes: 1
Reputation: 8398
Downgrading openssl worked for me,
brew switch openssl 1.0.2s
Upvotes: 9
Reputation: 1400
I had a similar problem on OSX 10.11 due to installing memcached which installed python 3.7 on top of 3.6.
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Spent hours on unlinking openssl, reinstalling, changing paths.. and nothing helped. Changing openssl version back from to older version did the trick:
brew switch openssl 1.0.2e
I did not see this suggestion anywhere in internet. Hope it serves someone.
Upvotes: 52
Reputation: 141
I finally solve this issue. These are the detail of my env:
Version of Python to install: 3.6.8
OS: Ubuntu 16.04.6 LTS
Root access: No
Some people suggest to install libssl-dev
, but it did not work for me. I follow this link and I fixed it!
In short, I download, extract, build, and install OpenSSL (openssl-1.1.1b.tar.gz). Then, I modify .bashrc
file follow this link.
Next, I download and extract Python-3.6.8.tgz. I edit Modules/Setup.dist to modify SSL path (lines around #211). I did ./configure --prefix=$HOME/opt/python-3.6.8
, make
and make install
. Last, I modify my .bashrc
. Notice that I do not include --enable-optimizations
in ./configure
.
Upvotes: 2
Reputation: 163
You can do either of these two:
or
\Anaconda
\Anaconda\Library\mingw-w64\bin
\Anaconda\Library\usr\bin
\Anaconda\Library\bin
\Anaconda\Scripts
\anaconda\Library
\anaconda\condabin
Add the above paths to the "Path" system variable and it should show the error no more :)
Upvotes: 6
Reputation: 2753
Ok the latest answer to this, as of now don't use Python 3.8, use only 3.7 or less , because of most of the libraries fail to install with the above error
Upvotes: -1
Reputation: 13
If you are on OSX and in case the other solutions didn't work for you (just like me).
You can try uninstalling python3 and upgrade pip3
brew uninstall --ignore-dependencies python3
pip3 install --upgrade pip
This worked for me ;)
Upvotes: 1
Reputation: 35984
my issue appeared related to my python installation and was quickly resolved by re-installing python3 and pip. i think it started misbehaving after an OS update but who knows (at this time I am on Mac OS 10.14.6)
brew reinstall python3 --force
# setup pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
# installa pkg successfully
pip install pandas
Upvotes: 7
Reputation: 63
On macos, configure python 3.8.1 with the command below will solve the problem, i think it would also work on Linux.
./configure --enable-optimizations --with-openssl=/usr/local/opt/[email protected]/
change the dir parameter based on your system.
Upvotes: 0
Reputation: 51
In my case with using Mac, I deleted
/Applications/Python 3.7
.
because I already had Python3.7 by brew install python3
.
But it was a trigger of the message
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
What I did in my situation
/Applications/Python3.6/Install Certificates.command
and /Applications/Python3.6/Update Shell Profile.command
.pip.conf
. See pip install fails.Upvotes: 2
Reputation: 441
Agree with the answer by mastaBlasta. Worked for me. I encountered the same problem as the topic description.
Environment: MacOS Sierra. And I use Homebrew.
My solution:
brew uninstall openssl; brew install openssl
According to the hints given by Homebrew, 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"
Upvotes: 34
Reputation: 3457
The ssl
module is a TLS/SSL wrapper for accessing Operation Sytem (OS) socket (Lib/ssl.py). So when ssl
module is not available, chances are that you either don't have OS OpenSSL libraries installed, or those libraries were not found when you install Python. Let assume it is a later case (aka: you already have OpenSSL installed, but they are not correctly linked when installing Python).
I will also assume you are installing from source. If you are installing from binary (ie: Window .exe file), or package (Mac .dmg, or Ubuntu apt), there is not much you can do with the installing process.
During the step of configuring your python installation, you need to specify where the OS OpenSSL will be used for linking:
# python 3.8 beta
./configure --with-openssl="your_OpenSSL root"
So where will you find your installed OpenSSL directory?
# ubuntu
locate ssl.h | grep '/openssl/ssl.h'
/home/user/.linuxbrew/Cellar/openssl/1.0.2r/include/openssl/ssl.h
/home/user/envs/py37/include/openssl/ssl.h
/home/user/miniconda3/envs/py38b3/include/openssl/ssl.h
/home/user/miniconda3/include/openssl/ssl.h
/home/user/miniconda3/pkgs/openssl-1.0.2s-h7b6447c_0/include/openssl/ssl.h
/home/user/miniconda3/pkgs/openssl-1.1.1b-h7b6447c_1/include/openssl/ssl.h
/home/user/miniconda3/pkgs/openssl-1.1.1c-h7b6447c_1/include/openssl/ssl.h
/usr/include/openssl/ssl.h
Your system may be different than mine, but as you see here I have many different installed openssl libraries. As the time of this writing, python 3.8 expects openssl 1.0.2 or 1.1:
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
So you would need to verify which of those installed libraries that you can use for linking, for example
/usr/bin/openssl version
OpenSSL 1.0.2g 1 Mar 2016
./configure --with-openssl="/usr"
make && make install
You may need to try a few, or install a new, to find the library that would work for your Python and your OS.
Upvotes: 5
Reputation: 704
I tried A LOT of ways to solve this problem and none solved. I'm currently on Windows 10.
The only thing that worked was:
Then I've downloaded all the libs I needed using PIP... and worked!
Don't know why, or if the problem was somehow related to Anaconda.
Upvotes: 7
Reputation: 435
If you are on Windows and use Anaconda you can try running "pip install ..." command in Anaconda Prompt instead of cmd.exe, as user willliu1995 suggests here. This was the fastest solution for me, that does not require installation of additional components.
Upvotes: 12
Reputation: 1368
If you are on Windows and use anaconda this worked for me:
I tried a lot of other solutions which did not work (Environment PATH Variable changes ...)
The problem can be caused by DLLs in the Windows\System32 folder (e.g. libcrypto-1_1-x64.dll or libssl-1_1-x64.dll or others) placed there by other software.
The fix was installing openSSL from https://slproweb.com/products/Win32OpenSSL.html which replaces the dlls by more recent versions.
Upvotes: 118
Reputation: 750
I encountered the same problem on windows 10. My very specific issue is due to my installation of Anaconda. I installed Anaconda and under the path Path/to/Anaconda3/
, there comes the python.exe
. Thus, I didn't 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 the following:
1) you can download python again on the official website;
2) Navigate to the directory where "Python 3.7 (64-bit).lnk"
is located
3) import ssl
and exit()
4) type in cmd, "Python 3.7 (64-bit).lnk" -m pip install tensorflow
for instance.
Here, you're all set.
Upvotes: 6
Reputation: 539
In Ubuntu, this can help:
cd Python-3.6.2
./configure --with-ssl
make
sudo make install
Upvotes: 42
Reputation: 21
I was having the same issue and was able to resolve with 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
depending on perms, you may not need sudo.
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 perms, you can also add the --user flag like so:
pip3.7 install pandas --user
Upvotes: 2
Reputation: 606
I had the same issue trying to install python3.7 on an ubuntu14.04 machine. The issue was that I had some custom folders in my PKG_CONFIG_PATH and in my LD_LIBRARY_PATH, which prevented the python build process to find the system openssl libraries.
so try to clear them and see what happens:
export PKG_CONFIG_PATH=""
export LD_LIBRARY_PATH=""
Upvotes: -1
Reputation: 129
The python documentation is actually very clear, and following the instructions did the job whereas other answers I found here were not fixing this issue.
first, install python 3.x.x from source using, for example with version 3.6.2 https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
make sure you have openssl installed by running brew install openssl
unzip it and move to the python directory: tar xvzf Python-3.6.2.tar.xz && cd Python-3.6.2
then if the python version is < 3.7, run
CPPFLAGS="-I$(brew --prefix openssl)/include" \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
./configure --with-pydebug
5. finallly, run make -s -j2
(-s
is the silent flag, -j2
tells your machine to use 2 jobs)
Upvotes: -1