“Python 中的 ssl 模块不可用”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49094768/
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
"ssl module in Python is not available"
提问by gRookie
still advancing in my tutorial to learn python, I was told to do
在我的教程中仍在推进学习 python,我被告知要做
sudo -H pip install requests
I get the following :
我得到以下信息:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting requests
Could not fetch URL https://pypi.python.org/simple/requests/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
Could not find a version that satisfies the requirement requests (from versions: )
No matching distribution found for requests
would someone know what I need to do to fix that once for all ?
有人会知道我需要做什么才能一劳永逸地解决这个问题吗?
thanks so much in advance
非常感谢提前
回答by Esmaeil MIRZAEE
I use Linux distros and face the problem since the new installation of Python 3.6. I tried a couple of solution and finally solved the problem. The steps I followed are as below.
自新安装 Python 3.6 以来,我使用 Linux 发行版并面临问题。我尝试了几种解决方案,最终解决了问题。我遵循的步骤如下。
On Debian like distros
在 Debian 之类的发行版上
sudo apt-get install build-essential checkinstall libreadline-gplv2-dev ibncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
Change the directory to the Python3.6 location
将目录更改为 Python3.6 位置
cd /path/to/Python3.6/Module/
In the module directory, open the Setup
file with your preferred text editor
在模块目录中,Setup
使用您喜欢的文本编辑器打开文件
vi Setup
Search for SSL
and uncomment the related lines.
搜索SSL
并取消注释相关行。
ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
Save the file and on the root folder of your Python package, run the following command.
保存文件并在 Python 包的根文件夹中运行以下命令。
make
sudo make install
And finally, run the pip3
to install your required module(s).
最后,运行pip3
以安装所需的模块。
回答by Arunraj Nair
Running ./configure
with --enable-optimizations
did the trick.
./configure
与运行一起--enable-optimizations
做的伎俩。
Here are the steps that worked for me on a Ubuntu 16.04 LTS box-
以下是在 Ubuntu 16.04 LTS 机器上对我有用的步骤-
The lines related to
ssl
in theModules/Setup*
files are commentedcd to the directory where you have the Python tar extracted
cd /../../../Python-3.7.4/
Run configure with optimizations enabled
./configure --enable-optimizations
Run make and then make install
make
make install
相关线路
ssl
在Modules/Setup*
文件注释cd 到您提取 Python tar 的目录
cd /../../../Python-3.7.4/
在启用优化的情况下运行配置
./configure --enable-optimizations
运行 make 然后 make install
make
make install
回答by Eric Grinstein
I encountered this problem running pip on Powershell on Windows, using the Anaconda distribution. I was running it inside VSCode, but I don't think it makes much difference.
我使用 Anaconda 发行版在 Windows 上的 Powershell 上运行 pip 时遇到了这个问题。我在 VSCode 中运行它,但我认为它没有太大区别。
A quick turnaround for me was installing what I needed using the Anaconda prompt, which works fine.
对我来说,快速周转是使用 Anaconda 提示符安装我需要的东西,它工作正常。
回答by Zeyar Aung
I encountered the same problem in Windows 10.
我在 Windows 10 中遇到了同样的问题。
What I did was:
我所做的是:
Step 1:go to https://pypi.python.org/simple/requestsand download the latest version (e.g., requests-2.21.0.tar.gz).
第 1 步:前往https://pypi.python.org/simple/requests并下载最新版本(例如 requests-2.21.0.tar.gz)。
Step 2:unzip the downloaded file into a folder (e.g., c:\temp\requests-2.21.0). You can use 7zip for that purpose.
第二步:将下载的文件解压到一个文件夹中(例如,c:\temp\requests-2.21.0)。为此,您可以使用 7zip。
Step 3:pip install c:\temp\requests-2.21.0
第三步:pip install c:\temp\requests-2.21.0
Note: pip can also install a local folder.
注意:pip 也可以安装本地文件夹。
It worked for me.
它对我有用。
回答by xnf
este comando me funciono muy bien
este comando me funciono muy bien
This command worked very well for me.
这个命令对我来说非常有效。
cd Python-3.6.2
./configure --with-ssl
make
sudo make install