我使用的是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模块不可用

其他回答

Windows 10, Windows 7 如果pip install在CMD提示符下不工作,使用Anaconda提示符运行它-它工作。

https://github.com/pypa/virtualenv/issues/1139

在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。

为我工作。

pkg install openssl

使用此选项可以启用ssl。

我简单地用以下命令解决了这个问题:

Brew升级python@3.9

这个版本默认包含SSL !

操作系统一样,pyenv

如果你的python是pyenv安装的,其中pyenv是在macOS上安装的,可能有一个更新的版本可以修复这个问题:

$ brew update && brew upgrade pyenv

然后重新安装python版本:

$ pyenv install 3.7.2
pyenv: /Users/luckydonald/.pyenv/versions/3.7.2 already exists
continue with installation? (y/N) 

注意,像这样覆盖现有的python安装有点脏,但在我的例子中,它确实有效。可能更干净的方法是删除它,然后正确地重新创建。