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

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

当前回答

苹果操作系统

我在Mac OS(Mojave)上遇到了同样的问题,并解决了这个链接中提到的问题- Openssl问题。

如果你没有Homebrew或不知道什么是Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

或者如果你已经安装了Homebrew:

brew update && brew upgrade
brew uninstall --ignore-dependencies openssl; brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb

更新: 请记住,我必须使用——ignore-dependencies标记,因为安装的其他包依赖于OpenSSL。

另外,如果问题是在使用pyenv后引起的,您可以通过使用以下方法修复:

brew reinstall python

其他回答

我遇到了这个问题!我不小心安装了32位版本的Miniconda3。确保你选择的是64位版本!

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

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

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

操作系统一样,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安装有点脏,但在我的例子中,它确实有效。可能更干净的方法是删除它,然后正确地重新创建。

我得到了同样的错误:

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模块不可用

在我的情况下,我在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。