python pip安装问题

文章讲述了在遇到Python运行时的ModuleNotFoundError:Nomodulenamed_ssl错误后,如何检查pip已安装模块,发现openssl版本过低。然后,详细步骤是下载并编译安装openssl的新版本,再重新编译安装Python3.11,确保配置参数正确指向新openssl路径。最后,调整pip源至豆瓣以避免报错。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ModuleNotFoundError: No module named '_ssl'
查看pip安装了哪些模块
pip list
在这里插入图片描述
打开源码包中的文件
vim /opt/download/Python-3.11.2/Modules/Setup
在这里插入图片描述
自带的openssl版本太低了 重新编译和安装 openssl

wget https://www.openssl.org/source/openssl-1.1.1s.tar.gz
tar -zxf openssl-1.1.1s.tar.gz
./configure
make
make install

重新安装python3.11

./configure --prefix=/usr/local/python-3.11.2 --with-zlib=/usr/include/ --with-openssl-rpath=auto  --with-openssl=/usr/include/openssl  OPENSSL_LDFLAGS=-L/usr/include/openssl   OPENSSL_LIBS=-l/usr/include/openssl/ssl OPENSSL_INCLUDES=-I/usr/include/openssl
make
make install

导入模块测试
在这里插入图片描述

pip 阿里的源报错
vim ~/.pip/pip.conf

[global]
index-url = http://pypi.douban.com/simple
[install]
use-mirrors =true
mirrors =http://pypi.douban.com/simple/
trusted-host =pypi.douban.com
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值