[分享栈]centos7安装python3.8.5

1、切换到root账户

2、更新yum源

yum update

中间有询问过程,直接y同意更新就好了。

[分享栈]centos7安装python3.8.5_第1张图片

3、安装依赖项

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

[分享栈]centos7安装python3.8.5_第2张图片

4、下载python3.8.5

wget -P /home https://cdn.npm.taobao.org/dist/python/3.8.5/Python-3.8.5.tgz

[分享栈]centos7安装python3.8.5_第3张图片

5、解压

cd /home && tar -zxvf Python-3.8.5.tgz

[分享栈]centos7安装python3.8.5_第4张图片

6、配置编译

cd Python-3.8.5
mkdir /usr/local/python3.8.5
./configure --prefix=/usr/local/python3.8.5 
./configure --enable-optimizations  

如果出现错误信息:SystemError: returned NULL without setting an error generate-posix-vars failed;则需要升级gcc版本,请先升级gcc版本,参考链接centos7安装gcc10.2.0。

python385peizhi1.png

python385peizhi2.png

[分享栈]centos7安装python3.8.5_第5张图片

7、编译安装

make && make install

[分享栈]centos7安装python3.8.5_第6张图片

8、建立链接

ln -s /usr/local/python3.8.5/bin/python3 /usr/bin/python3  
ln -s /usr/local/python3.8.5/bin/pip3 /usr/bin/pip3

如果提示链接已存在,删除原链接即可。

python385link.png

9、查询版本

python3 --version

python385version.png

你可能感兴趣的:([分享栈]centos7安装python3.8.5)