pip 配置了需要 TLS/SSL 的位置,但是 Python 中的 ssl 模块不可用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45954528/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
提问by Santosh Kumar G
I am using Python3.6, when I try to install "modules" using pip3
, I am facing the below mentioned issue "pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available"
我正在使用 Python3.6,当我尝试使用 安装“模块”时pip3
,我面临下面提到的问题“pip 配置了需要 TLS/SSL 的位置,但是 Python 中的 ssl 模块不可用”
回答by u6772460
For Windows 10 if you want use pip in normal cmd, not only in Anaconda prompt. you need add 3 environment paths. like the followings:
对于 Windows 10,如果您想在普通 cmd 中使用 pip,而不仅仅是在 Anaconda 提示符中。您需要添加 3 个环境路径。像下面这样:
D:\Anaconda3;
D:\Anaconda3\Scripts;
D:\Anaconda3\Library\bin
most people only add D:\Anaconda3\Scripts;
大多数人只添加 D:\Anaconda3\Scripts;
回答by Vaulstein
MAC OS
苹果系统
I had the same problem on Mac OS(Mojave) and solved the problem as mentioned on this link - Openssl issue.
我在 Mac OS(Mojave) 上遇到了同样的问题,并解决了此链接中提到的问题 - Openssl 问题。
If you do not have Homebrew or don't know what is Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Or if you already have Homebrew installed:
如果您没有 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
Update:
Keep in mind, that I had to use --ignore-dependencies
flag, because other packages installed that depend on OpenSSL.
更新:请记住,我必须使用--ignore-dependencies
标志,因为安装的其他软件包依赖于 OpenSSL。
Additional if the problem is caused after using pyenv, you can fix it by using:
另外,如果问题是在使用pyenv后引起的,您可以使用以下方法修复它:
brew reinstall python
回答by Rafael B
For Debian users, the following may be of use:
对于 Debian 用户,以下可能有用:
sudo -s
apt install libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev libtk8.5 libgdm-dev libdb4o-cil-dev libpcap-dev
Then cd to the folder with the Python 3.X library source code and run:
然后 cd 到包含 Python 3.X 库源代码的文件夹并运行:
./configure
make
make install
回答by limboy
For future Oracle Linux users trying to solve this, below is what worked for me. First install missing libs:
对于未来试图解决此问题的 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
Then cd to your Python3.X library and run:
然后 cd 到您的 Python3.X 库并运行:
make
make install
回答by PDHide
For centos 7:
对于centos 7:
Install openssl:
安装openssl:
sudo yum install openssl-devel
now goto python directory were we extracted the python tar,
现在转到我们提取的python tar的python目录,
run below commands
运行以下命令
sudo ./configure
sudo make
sudo make install
This will fix the problem in centos...
这将解决centos中的问题...
回答by Tokci
For Windows 10,windows 7 If pip install is not working on CMD prompt, run it using Anaconda prompt - it works.
对于 Windows 10、Windows 7 如果 pip install 在 CMD 提示符下不起作用,请使用 Anaconda 提示符运行它 - 它可以工作。
回答by Evgeny
For OpenSUSE in the same manner, but a few changes of listed above packages:
对于 OpenSUSE 以相同的方式,但对上面列出的软件包进行了一些更改:
zypper install zlib-devel libopenssl-devel ncurses-devel sqlite3-devel readline-devel tk-devel gdbm-devel libpcap-devel xz-devel
Then cd
to Python sources dir and
然后cd
到 Python 源目录和
make
make install
or
或者
make
make altinstall
And perhaps
也许
ln -s /usr/local/lib64/python3.6/lib-dynload/ /usr/local/lib/python3.6/lib-dynload
should be executed for OpenSUSE users. See Python 3.7 install not working on openSUSE Leap 42.3
应该为 OpenSUSE 用户执行。参见Python 3.7 install not working on openSUSE Leap 42.3
回答by Nishant Wattamwar
Just try installing through Anaconda prompt
只需尝试通过 Anaconda 提示符安装
回答by naman1994
Worked for me.
为我工作。
apt-get install libssl-dev
Use this to enable ssl for pip. Let me know if someone encounters issues.
使用它来为 pip 启用 ssl。如果有人遇到问题,请告诉我。
回答by FastGTR
I ran into this issue with Visual Studio Code installing pylint from the VS Code prompt. I was able to overcome the issue by opening the Anaconda installation directory and running
我在使用 Visual Studio Code 从 VS Code 提示安装 pylint 时遇到了这个问题。我能够通过打开 Anaconda 安装目录并运行来解决这个问题
pip install pylint
Then VS Code was happy, but that did not fix the issue as running
然后 VS Code 很高兴,但这并没有解决运行问题
& C:/Users/happy/Anaconda3/python.exe -m pip install -U pylint
pretty much gave the same error so it seems that VS Code is unable to access the python modules.
几乎给出了相同的错误,因此似乎 VS Code 无法访问 python 模块。
Note that VS Code picks up the first python env it see when installed, the bottom left of the screen indicates which env is being used. Clicking on that area allows to set the environment. So even if you ran the pip install for an environment VS Code could be looking at a different one.
请注意,VS Code 在安装时会选择它看到的第一个 python 环境,屏幕左下角指示正在使用哪个环境。单击该区域可以设置环境。因此,即使您为某个环境运行了 pip install,VS Code 也可能会查看不同的环境。
Best approach was to make sure that VS code had the correct python environment selected and that same environment is in the system PATH (under System Properties --> Advanced --> Environmental Variables)
最好的方法是确保 VS 代码选择了正确的 python 环境,并且相同的环境在系统路径中(在系统属性 --> 高级 --> 环境变量下)
Under the Path Variable, Edit and browse to the specific Anaconda directory that you want VSCode to use and add to PATH, I needed to Add the following:
在路径变量下,编辑并浏览到您希望 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\
Your Anaconda installation directory may differ. One note is that Windows does not have the PATH variable take effect until you restart the terminal. In this case close and re-op VS code. If using a Terminal or PS Shell then close and reopen and check Path to make sure it is included.
您的 Anaconda 安装目录可能不同。一个注意事项是,在您重新启动终端之前,Windows 不会使 PATH 变量生效。在这种情况下,关闭并重新操作 VS 代码。如果使用终端或 PS Shell,则关闭并重新打开并检查路径以确保它被包含在内。