我使用的是Python 3.6。当我尝试使用pip3安装“模块”时,我遇到了这个问题:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
我使用的是Python 3.6。当我尝试使用pip3安装“模块”时,我遇到了这个问题:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
当前回答
在我的情况下,我在Linux上的$PATH遇到了问题。这也可能发生在MacOS上。
检查/usr/bin/pip3 install package_name_goes_here是否适合您。如果是,那么运行 这将告诉您pip3安装在哪个目录中。
如果它类似于/usr/local/bin/pip3,与/usr/bin/pip3不同,那么您可能需要调整您的$PATH。
运行 echo $PATH并复制结果。
PATH只是一个冒号分隔的包含目录的目录列表。Bash将始终返回您试图执行的程序的第一个实例。将所有系统目录移到前面。下面是一些系统目录的列表:
/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
如果失败,则验证您已经安装了openssl,运行openssl version -a如果没有,则安装openssl。
其他回答
进入Anaconda提示符并输入(如果你有python3。X安装在你的引擎上):
py -m pip install pymysql
我也有同样的问题,这个解决了我的问题。之后,您可以在power shell或任何其他提示符中导入pymysql。
这招对我很管用:
yum install python36-pyOpenSSL
Python版本和包管理器可能不同。
为我工作。
sudo apt-get install libssl-dev
使用此选项为pip启用ssl。 如果有人遇到问题请告诉我。
我用的是macOS,我用过brew,但Vaulstein在他的回答中提到的并没有涵盖我的情况。
我运行以下命令,以确保我当前的python没有通过brew安装
brew list | grep python
python
python@2
brew info python
python@3.8: stable 3.8.3 (bottled)
Interpreted, interactive, object-oriented programming language
https://www.python.org/
Not installed
...
所以我从https://www.python.org/下载了最新的3.8.5,安装时我看到了以下信息
证书验证和OpenSSL 此包包含自己的私有OpenSSL 1.1.1副本。的 管理的系统和用户密钥链中的信任证书 Python ssl模块不默认使用Keychain Access应用程序和安全命令行实用程序
在安装3.8.5之后,它修复了这个问题。
我得到了同样的错误:
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模块不可用