Python3.11版本pip遇到ssl报错

刚装上Python3.11,使用pip过程中出现 TLS/SSL 报错

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

解决方案:

下载并安装 openssl-1.1.1s 版本,编译参考该链接

wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1s.tar.gz 
tar zxf openssl-1.1.1s.tar.gz 
cd openssl-1.1.1s
./config -fPIC -shared --prefix=/path/to/openssl-1.1.1s_build
make && make install 

安装好openssl之后,重新安装python3.11

cd Python-3.11.1
./configure -enable-optimizations --enable-shared --enable-loadable-sqlite-extensions --with-openssl-rpath=auto --prefix=/path/to/Python-3.11.1_build --with-openssl=/path/to/openssl-1.1.1s_build
make && make install 
export LD_LIBRARY_PATH=/path/to/Python-3.11.1_build/lib:$LD_LIBRARY_PATH

下载pandas测试python3是否可用

./Python-3.11.1_build/bin/python3 -m pip install pandas

发现太慢了,参考CSDN博客将国内镜像直接添加到配置中

mkdir -p ~/.pip
vi ~/.pip/pip.conf

将下面内容添加到 ~/.pip/pip.conf文件中,保存退出

[global]
timeout = 8
index-url = http://mirrors.aliyun.com/pypi/simple/
extra-index-url = http://pypi.douban.com/simple/
[install]
trusted-host=
  mirrors.aliyun.com
  pypi.douban.com

重新下载,安装成功!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容