问题描述
在安装python环境之后,使用pip下载相应的依赖,出现如下的错误:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting bottle
Could not fetch URL https://pypi.python.org/simple/bottle/: 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 bottle (from versions: )
No matching distribution found for bottle
一些回答给出的方案是使用yum
安装openssl
,但是在Ubuntu上一般使用yum时会显示仓库为空,这种方法很麻烦,容易失败
1. 使用apt-get安装ssl
sudo apt-get install openssl
sudo apt-get install libssl-dev
2. 在pip对应的刚刚安装的python解压目录下修改Modules/Setup
cd Python3.x.x
vim Modules/Setup
3. 修改的部分
#Socket module helper for socket(2)
_socket socketmodule.c timemodule.c
#Socket module helper for SSL support; you must comment out the other
#socket line above, and possibly edit the SSL variable:
#SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
也就是有的注释的地方去掉。
4. 重新编译安装原来的python
这一步骤是必要的,安装完成后,测试:
>>>import ssl
>>>
出现如上则说明安装成功。
完结撒花🌼🌼🌼🌼