Ubuntu使用pip安装时出现的网络问题:ssl module in Python is not available

问题描述

在安装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  
>>> 

出现如上则说明安装成功。
完结撒花🌼🌼🌼🌼

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值