我使用的是Python 3.6。当我尝试使用pip3安装“模块”时,我遇到了这个问题:

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

当前回答

我得到了同样的错误:

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

在《Anaconda》中,我使用了以下命令:

conda install anaconda-navigator

本文中提到:pip配置了需要TLS/SSL的位置,但是Python中的SSL模块不可用

其他回答

centos 7:

安装openssl:

sudo yum install openssl-devel

现在进入python目录,在那里我们提取了python tar文件,

运行以下命令

sudo ./configure
sudo make
sudo make install

这将解决centos的问题…

Windows 10 如果你想在正常的cmd中使用pip,而不仅仅是在Anaconda提示符中。您需要添加3个环境路径。 比如:

D:\Anaconda3 
D:\Anaconda3\Scripts
D:\Anaconda3\Library\bin 

大多数人只添加D:\Anaconda3\Scripts

在ubuntu上从源代码安装python 3.8时遇到了这个问题。下面总结了成功安装默认python 3.7所需的步骤:

sudo apt -y install libssl-dev zlib1g-dev build-essential

wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
tar -xf Python-3.8.0.tgz
cd Python-3.8.0/

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

zlib1g-dev和build-essential的安装说明是多余的,因为ubuntu桌面已经有了这些,但对于Amazon的一些EC2实例来说是必要的。Python 3.8.0是目前的最新版本,但应该被最新的可用版本所取代。

这些指令最适合将python 3.7作为python3的默认值,并在虚拟环境中运行python 3.8。

与上述解决方案类似,使用pyenv重新安装python版本。

不知何故,我升级了我的openssl,它破坏了pyenv版本的python。

pyenv install 3.6.8
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
...

第一行说它依赖于自制的openssl。

只要尝试通过Anaconda提示安装即可