Centos编译安装Python3.9
2022/1/12 7:07:36
本文主要是介绍Centos编译安装Python3.9,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
安装编译相关工具
yum -y groupinstall "Development tools" yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel yum install libffi-devel -y
下载python安装包
wget http://npm.taobao.org/mirrors/python/3.9.9/Python-3.9.9.tgz tar -zxvf Python-3.9.9.tgz
编译安装python
mkdir /usr/local/python3 #创建编译安装目录
cd Python-3.9.9 ./configure --prefix=/usr/local/python3 make && make install
安装过,出现下面两行就成功了
Installing collected packages: setuptools, pip
Successfully installed pip-21.2.4 setuptools-58.1.0
创建软连接
# 查看当前python软连接
/usr/bin/ |grep python lrwxrwxrwx 1 root root 7 Nov 26 2018 python -> python2 lrwxrwxrwx 1 root root 9 Nov 26 2018 python2 -> python2.7 -rwxr-xr-x 1 root root 7216 Jul 13 2018 python2.7
默认系统安装的是python2.7
删除python软连接
rm -rf /usr/bin/python
配置软连接为python3
#添加python3的软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python python -V Python 3.9.9
删除默认pip软连接,并添加pip3新的软连接
rm -rf /usr/bin/pip
#添加 pip3 的软链接
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
更改yum配置
因为其要用到python2才能执行,否则会导致yum不能正常使用(不管安装 python3的那个版本,都必须要做的)
vi /usr/bin/yum 把 #! /usr/bin/python 修改为 #! /usr/bin/python2 vi /usr/libexec/urlgrabber-ext-down 把 #! /usr/bin/python 修改为 #! /usr/bin/python2 vi /usr/bin/yum-config-manager #!/usr/bin/python 改为 #!/usr/bin/python2
这篇关于Centos编译安装Python3.9的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-14获取参数学习:Python编程入门教程
- 2024-11-14Python编程基础入门
- 2024-11-14Python编程入门指南
- 2024-11-13Python基础教程
- 2024-11-12Python编程基础指南
- 2024-11-12Python基础编程教程
- 2024-11-08Python编程基础与实践示例
- 2024-11-07Python编程基础指南
- 2024-11-06Python编程基础入门指南
- 2024-11-06怎么使用python 计算两个GPS的距离功能-icode9专业技术文章分享