1. 首页
  2. IT教程

[分享栈]centos7安装python3.8.5

1、切换到root账户

2、更新yum源

yum update

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

[分享栈]centos7安装python3.8.5

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

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

5、解压

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

[分享栈]centos7安装python3.8.5

6、配置编译

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

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

[分享栈]centos7安装python3.8.5

[分享栈]centos7安装python3.8.5

[分享栈]centos7安装python3.8.5

7、编译安装

make && make install

[分享栈]centos7安装python3.8.5

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

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

[分享栈]centos7安装python3.8.5

9、查询版本

python3 --version

[分享栈]centos7安装python3.8.5

原创文章,作者:夜风博客,如若转载,请注明出处:https://www.homedt.net/39140.html