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

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

当前回答

你可以去蟒蛇餐厅试试。

你会看到(基础),现在升级pip。 例子:

(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

这将花费较长的时间,但也将安装或升级Anaconda内部使用的SSL库。继续前进

其他回答

对于未来试图解决这个问题的Oracle Linux用户,下面是对我有用的方法。 首先安装缺少的库:

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel 
readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

然后cd到Python3。X库并运行:

make
make install 

为我工作。

sudo apt-get install libssl-dev

使用此选项为pip启用ssl。 如果有人遇到问题请告诉我。

对于Windows 10下的Miniconda3, python=3.7.5,我尝试了以上所有建议;毫无效果。我不得不降级到python=3.7.0,这解决了这个问题

conda install python=3.7.0

显然这很混乱。答案表明升级到3.8.5也可以工作,但这在我的环境中有太多的副作用。

先安装openssl。

如果你在conda环境中遇到这个问题,你可以安装openssl 使用conda install -c anaconda openssl。它为您启用ssl !

我在Visual Studio Code从VS Code提示安装pylint时遇到了这个问题。 通过打开Anaconda安装目录并运行,我能够克服这个问题

pip install pylint

然后VS Code很高兴,但这并没有解决运行时的问题

& C:/Users/happy/Anaconda3/python.exe -m pip install -U pylint

基本上都给出了相同的错误,所以看起来VS Code无法访问python模块。

注意,VS Code在安装时选择了它看到的第一个python env,屏幕的左下角表示正在使用哪个env。单击该区域可以设置环境。所以即使你在一个环境中运行pip安装,VS Code也可能会看到一个不同的环境。

最好的方法是确保VS代码选择了正确的python环境,并且相同的环境在系统路径中(在系统属性->高级->环境变量下)

在Path变量下,编辑并浏览到你想要VSCode使用并添加到Path的特定Anaconda目录,我需要添加以下内容:

C:\Users\happy\Anaconda3\
C:\Users\happy\Anaconda3\Scripts\
C:\Users\happy\Anaconda3\Library\bin\
C:\Users\happy\Anaconda3\Library\mingw-w64\bin\

您的Anaconda安装目录可能不同。 需要注意的是,Windows直到重新启动终端才使PATH变量生效。在这种情况下,关闭并重新操作VS代码。如果使用终端或PS Shell,则关闭并重新打开并检查路径,以确保它包括在内。