ubuntu18容器内编译安装python3.9后,pip安装失败问题

 

参考文档

https://www.jianshu.com/p/8a17267caf5f
https://blog.csdn.net/youxijishu/article/details/128885291
https://blog.csdn.net/Beyond_F4/article/details/104004626
https://zhuanlan.zhihu.com/p/598697953?utm_id=0
https://www.myfreax.com/how-to-install-python-3-8-on-ubuntu-18-04/

 

安装依赖包以及python源文件包
sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev \
libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev \
libreadline-dev libffi-dev curl libbz2-dev curl -y

curl -O https://www.python.org/ftp/python/3.9.15/Python-3.9.15.tar.xz


如果没有openssl/include,需要编辑安装

使用whereis openssl, which openssl先查看下
#下载源码包
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
#解压
tar -zxvf openssl-1.1.1g.tar.gz
#进入文件夹
cd openssl-1.1.1g/
#配置指定安装目录
./config --prefix=/usr/local/openssl
#编译安装
make -j8 && make install

如果安装失败,可能需要修改ssl配置
进入解压后的源码安装包
vim Module/Setup
去掉209-212行的注释, 不同版本行数有区别
214 #SSL=/usr/local/ssl 如果是上面自己安装的openssl,需要修改为/usr/local/openssl
215 #_ssl _ssl.c \
216 # -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
217 # -L$(SSL)/lib -lssl -lcrypto

 

./configure --prefix=/usr/local/python3.9.15 #这里不要添加ssl模块

pip3 install -i https://pypi.douban.com/simple boto3

posted @ 2024-01-29 11:21  坚强的小蚂蚁  阅读(62)  评论(0编辑  收藏  举报