python import ssl失败_python安装过程中_ssl、依赖包缺失,导致pip失败的问题

环境:

python:3.6.9

ubuntu:16.04.5

新拿到远程服务器,配置环境需要用到pipenv,在 pip install pipenv的时候,出现了以下错误:

Retrying (Retry(total=2, connect=None, read=None,

redirect=None, status=None)) after connection broken by

'SSLError("Can't connect to HTTPS URL because the SSL

module is not available.",)': /simple/pipenv/

...

...

Could not fetch URL https://pypi.org/simple/pip/: There was a

problem confirming the ssl certificate:

HTTPSConnectionPool(host='pypi.org', port=443): Max

retries exceeded with url: /simple/pip/ (Caused by

SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping

原因

系统缺少python的_ssl依赖包,在输入编译命令make test 后,发现有报错:

No module named :

'_ssl'、'_tkinter'、'_lzma'等

启动python,导入ssl模块发现也报错

$ python

Python 3.6.9 (default, Oct 21 2020, 08:00:24)

[GCC 5.4.0 20160609] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> import ssl

Traceback (most recent call last):

File "", line 1, in

File "/usr/local/lib/python3.6/ssl.py", line 101, in

import _ssl # if we can't import it, let the error propagate

ModuleNotFoundError: No module named '_ssl'

解决:

安装openssl,等python依赖包

sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

按照以下命令依次执行

./configure

sudo make

sudo make install

pip3 install package_name

相关链接:https://stackoverflow.com/questions/41328451/ssl-module-in-python-is-not-available-when-installing-package-with-pip3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值