centos7编译安装python3

1.安装依赖

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel

2.下载软件包

wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tar.xz

下载列表:https://www.python.org/ftp/python/

3.编译安装

wget http://www.openssl.org/source/openssl-1.1.1.tar.gz
tar xf openssl-1.1.1.tar.gz
cd openssl-1.1.1/
./config --prefix=/usr/local/openssl shared zlib
make && make install


tar -xf Python-3.9.7.tar
cd Python-3.9.7
./configure --prefix=/usr/local/python3.9  --with-ssl=/usr/local/openssl 
make && make install

 

如果使用系统默认版本,默认系统OpenSSL版本不适配,需要升级

yum install -y epel-release.noarch 
yum install -y openssl11 openssl11-devel

cd Python-3.10.xxx #进入目录后替换编译命令
# 替换openssl 为openssl11
sed -i 's/PKG_CONFIG openssl /PKG_CONFIG openssl11 /g' configure 

4.配置PATH及验证

vim ~/.bash_profile 
PATH=/usr/local/python3.9/bin:$PATH:$HOME/bin
. ~/.bash_profile 

env python3

  

  

  

  

posted @ 2023-02-20 15:08  百衲本  阅读(96)  评论(0编辑  收藏  举报
cnblogs_post_body { color: black; font: 0.875em/1.5em "微软雅黑" , "PTSans" , "Arial" ,sans-serif; font-size: 15px; } cnblogs_post_body h1 { text-align:center; background: #333366; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 23px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } cnblogs_post_body h2 { text-align:center; background: #006699; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 20px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } cnblogs_post_body h3 { background: #2B6695; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 18px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } 回到顶部 博客侧边栏 回到顶部 页首代码 回到顶部 页脚代码