Reputation: 5221
I am using Python 3.6. When I try to install "modules" using pip3
, I face this issue:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
Upvotes: 511
Views: 826573
Reputation: 148
On macOSX, I had this issue after upgrading my homebrew packages.
openssl
was upgraded from openssl1.1
to openssl@3
.
The solution was to remove openssl@3, and install [email protected] with homebrew:
brew remove openssl@3
brew install [email protected]
Upvotes: 2
Reputation: 4622
I'm using Windows 10 and installed Miniconda 3 with Python 3.7.
I solved this error by following this https://github.com/conda/conda/issues/8273
Specifically, I copied the following files from C:\Users\<user>\Miniconda3\Library\bin
to C:\Users\<user>\Miniconda3\DLLs
:
If you work in an environment, it will be from C:\Users\<user>\Miniconda3\envs\<name>\Library\bin
to C:\Users\<user>\Miniconda3\envs\<name>\DLLs
:
Upvotes: 95
Reputation: 163
This issue occurs when we compile python from source without installing some packages that helps with ssl. Here is how to fix this in a Debian based Linux system.
sudo apt install build-essential pkg-config zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev libbz2-dev
./configure --enable-optimizations
make -j 4
sudo make altinstall
Note that -j 4 specifies that I want to use 4 CPU threads. You can check how many threads your CPU has by running nproc
Upvotes: 3
Reputation: 1792
For Debian users, the following may be of use:
sudo apt install libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev libtk8.6 libgdm-dev libdb4o-cil-dev libpcap-dev
Then cd to the folder with the Python 3.X library source code and run:
./configure
make
sudo make install
Upvotes: 126
Reputation: 301
Even after trying all the above steps, i was getting the same error. So while we work in a lab and have authorised access to Internet,the issue was with old versions on servers. So i created a virtual environment and placed all my imported modules there. Gave all the necessary permission to the file and the user. Then i gave the internet access to the server system. It worked fine. Try checking for any access and permission issue you might have. Hope it helps. Thanks.
Upvotes: 0
Reputation: 587
After trying to compile python myself and still lacking the ssl module, i finally tried to just install the missing module from apt like this:
apt install python3-openssl
Upvotes: -1
Reputation: 377
Install openssl first.
If you are facing this issue in conda environment, you can install openssl
using conda install -c anaconda openssl
. It enables ssl for you!
Upvotes: -1
Reputation: 276
I was getting the same error:
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pb-tool/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pb-tool/
ERROR: Operation cancelled by user
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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
In Anaconda I did it with this command:
conda install anaconda-navigator
It was mentioned in this article : pip is configured with locations that require TLS/SSL however the ssl module in Python is not available
Upvotes: 0
Reputation: 6846
In case of your python being an pyenv
installed one, where pyenv is installed with homebrew on macOS, there might me a newer version available which fixes this:
$ brew update && brew upgrade pyenv
Then reinstalling the python version:
$ pyenv install 3.7.2
pyenv: /Users/luckydonald/.pyenv/versions/3.7.2 already exists
continue with installation? (y/N)
Note, it is a bit dirty to overwrite the existing python install like that, but in my case it did work out. Probably cleaner to delete it and then recreate it properly.
Upvotes: 44
Reputation: 22041
I had the same problem on Mac OS(Mojave) and solved the problem as mentioned on this link - Openssl issue.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update && brew upgrade
brew uninstall --ignore-dependencies openssl; brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb
Update:
Keep in mind, that I had to use --ignore-dependencies
flag, because other packages installed that depend on OpenSSL.
Additional if the problem is caused after using pyenv, you can fix it by using:
brew reinstall python
Upvotes: 255
Reputation: 363
Worked for me.
sudo apt-get install libssl-dev
Use this to enable ssl for pip. Let me know if someone encounters issues.
Upvotes: 21
Reputation: 398
If you've installed anaconda via scoop
, and encounter this error while using pip
from within a conda
environment you can resolve it by...
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current\Scripts
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current\Library
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current\Library\bin
openssl
via scoop
scoop install openssl
..\anaconda3\Library\bin
to ..\anaconda3\DLLs
References:
Upvotes: 1
Reputation: 2901
For Miniconda3 under Windows 10 with python=3.7.5 I tried all above suggestions; nothing worked. I had to downgrade to python=3.7.0 which solved the issue
conda install python=3.7.0
Obviously this is quite messy. The answers suggest that an upgrade to 3.8.5 might also work but this had too many side effects in my env.
Upvotes: -1
Reputation: 143
In my case I was running into issues with my $PATH
on Linux. This can also happen on MacOS.
Check to see if /usr/bin/pip3 install package_name_goes_here
works for you. If so then run
which pip3
this will tell you which is the first directory that pip3 is installed in.
If it is something like /usr/local/bin/pip3
which is different from /usr/bin/pip3
then you may need to adjust your $PATH.
Run
echo $PATH
and copy the result.
The PATH is simply a colon separated list of directories that contain directories. Bash will always return the first instance of the program that you are attempting to execute. Move all the system directories upfront. Here is a list of some of the system directories:
/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
If that fails then verify you have openssl
installed by running openssl version -a
if not then install openssl.
Upvotes: 1
Reputation: 55
In Windows 10 SQL Server 19 the solution is known.
Copy the following files:
from the folder
C:\Program Files\Microsoft SQL Server\MSSSQL15.MSSQLSERVER\PYTHON_SERVICES\Library\bin
to the folder
C:\Program Files\Microsoft SQL Server\MSSSQL15.MSSQLSERVER\PYTHON_SERVICES\DLLs
Then open a new DOS command shell prompt.
Upvotes: 2
Reputation: 437
I simply solved the problem with following command:
brew upgrade [email protected]
SSL is included by default on this version!
Upvotes: 1
Reputation: 300
I had the same issue and it was because I changed the folder of the environment. I just removed the env and reinstalled everything.
Upvotes: 0
Reputation: 23467
I got into this problem using Ubuntu, pyenv and Python 3.8.1 managed by pyenv. There was actually no way to get pip to work correctly, since every time I tried to install anything, including pip itself, the same error showed up. Final solution was to install, via pyenv, a newer version, in this case 3.8.6. Apparently, from 3.8.4 Python is prepared to run SSL/TLS out of the box, so everything worked fine.
Upvotes: 1
Reputation: 4317
For Windows 10 if you want use pip in normal cmd, not only in Anaconda prompt. you need add 3 environment paths. like the followings:
D:\Anaconda3
D:\Anaconda3\Scripts
D:\Anaconda3\Library\bin
most people only add D:\Anaconda3\Scripts
Upvotes: 370
Reputation: 12395
I am on macOS and I had used brew but what Vaulstein mentioned in his answer didn't cover my case.
I run the following commands to make sure my current python was not installed by brew
brew list | grep python
python
python@2
brew info python
[email protected]: stable 3.8.3 (bottled)
Interpreted, interactive, object-oriented programming language
https://www.python.org/
Not installed
...
So I download the latest 3.8.5 from https://www.python.org/ and when installing it I saw following information
Certificate verification and OpenSSL
This package includes its own private copy of OpenSSL 1.1.1. The trust certificates in system and user keychains managed by the Keychain Access application and the security command line utility are not used as defaults by the Python ssl module
After installed 3.8.5 it fixed the problem.
Upvotes: 1
Reputation: 109
In my case, I reinstalled Python. It solved the problem.
brew reinstall python
Upvotes: 7
Reputation: 1410
You could try brew link
and it will show you the proper instruction:
$ brew link openssl --force
Warning: Refusing to link macOS provided/shadowed software: [email protected]
If you need to have [email protected] first in your PATH run:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
For compilers to find [email protected] you may need to set:
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
For pkg-config to find [email protected] you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
Upvotes: 0
Reputation: 5223
Newest Python 3.8.4 or higher should able to support https protocol out of box. If you still have old python installation on your pc - either download & install python3 manually, or using Chocolatey:
If you don't have Chocolatey, install it - from here: https://chocolatey.org/docs/installation
You can just copy paste one command line liner and execute it from command prompt with elevated priviledges.
choco install python3
if you don't have python3 installed, or you you have it installed - then:
choco upgrade python3
Notice also that you can use also anaconda distribution, as it has built-in python with https support, but this rather ancient instructions, no need to follow them anymore.
Install anaconda, using command line:
choco install anaconda3
Set environment variables:
set PATH=C:\tools\Anaconda3\Scripts;C:\tools\Anaconda3;C:\tools\Anaconda3\Library\bin;%PATH%
and then run command which failed. In my case it was:
pip install conan
Anaconda uses separate python installation, and pip is also anaconda specific.
Upvotes: 5
Reputation: 966
The issue is due to OpenSSL package is missing on your PC.
If pip install openpyxl
also gives error.
you can fix this by installing OpenSSL(Win64 OpenSSL v1.1.1g) from below site :
slproweb.com/products/Win32OpenSSL.html
Restart the IDE you are using, for changes to be in effect.
Upvotes: 2
Reputation: 3105
Similar to the above solution reinstall the python version with pyenv.
Somehow, I upgraded my openssl
which broke the pyenv version python.
pyenv install 3.6.8
python-build: use [email protected] from homebrew
python-build: use readline from homebrew
...
The first line says it relies on the homebrew openssl.
Upvotes: 9
Reputation: 589
You’d try from Anaconda Prompt.
You will see (base), now upgrade pip. Example:
(base) C:\Users\Tom>cd ..
(base) C:\Users>cd ..
(base) C:\>python -m pip install --upgrade pip
Requirement already up-to-date: pip in g:\anaconda3\lib\site-packages (20.0.2)
(base) C:\>pip -V
pip 20.0.2 from G:\Anaconda3\lib\site-packages\pip (python 3.7)
# Try install
(base) C:\>pip install selenium
This takes a longer time, but will also install or upgrade SSL libraries that Anaconda uses internally. Keep Going here
Upvotes: 0
Reputation: 865
The problem probably comes from your installed openssl package version. That was the case for me and I fixed this issue just upgrading it. I'm on Mac OS, using brew :
brew upgrade openssl
If you installed python with brew, this should directly fix the issue with it, as python is dependent on openssl
Upvotes: 5
Reputation: 2790
Fixed this without having to change anything related to TSL/SSL.
I was trying to see if the same thing was happening to pip
, and saw that pip
was broken. Did some digging and realized it's probably caused by Homebrew deleted python@2
on February 1st, 2020.
Running brew uninstall python@2
to delete python2 installed by Homebrew.
Destroyed the virtual env created using python3
and created a new one. pip3
installing works fine again.
Upvotes: 1