pip安装模块出现pip is configured with locations that require TLS/SSL问题

pip安装模块出现pip is configured with locations that require TLS/SSL问题

原因

有可能你的python解释器是编译安装的,因为编译安装比较纯净,在安装的时候没有指定ssl这个模块,所以造成你在pip install的时候出现报错

你可以进入解释器去实验

zonghan@MacBook-Pro bin % python3.9
Python 3.9.14 (main, Oct 29 2022, 23:49:16) 
[Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> import _ssl
>>> 

如果上述命令报错,说明确实没有ssl这个模块

解决方法

1.首先先把之前编译安装的数据清除,进入你编译安装python解释器的那个安装包

cd /Users/zonghan/Downloads/Python-3.9.14
make clean && make distclean

2.下载并安装openssl包

官网https://www.openssl.org/

我在这里下载的是下图版本

image

编译安装

tar -zxvf openssl-3.0.5.tar.gz
cd openssl-3.0.5
# 编译安装
./config --prefix=/usr/local/openssl no-zlib #不需要zlib
make
make install

3.重新安装python
在这里指定ssl

./configure --prefix=/usr/local --enable-shared  --enable-optimizations --with-openssl=/usr/local/openssl

make

make install

验证

image

问题解决

posted @ 2022-10-30 00:18  zong涵  阅读(1312)  评论(0编辑  收藏  举报