centos7 部署python39

centos7 自带的python版本是2.7,但是现在很多python项目需要python3.9以上的版本,所以需要自己手动部署python3.9。这里记录一下部署python3.9的过程。

安装依赖

1
2
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel

下载安装包

1
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz

解压安装包

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 解压压缩包
tar -zxvf Python-3.9.0.tgz

# 进入文件夹
cd Python-3.9.0

# 配置安装位置
./configure prefix=/usr/local/python3

# 安装
make && make install

添加软连接

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
[root@centos-moxc bin]# ln -s /usr/local/python3/bin/python3.9 /usr/bin/python3
[root@centos-moxc bin]# ln -s /usr/local/python3/bin/pip3.9 /usr/bin/pip3
[root@centos-moxc bin]# python3 -V
Python 3.9.0
[root@centos-moxc bin]# pip3 -V
pip 20.2.3 from /usr/local/python3/lib/python3.9/site-packages/pip (python 3.9)

# 查看软连接指向
[root@centos-moxc bin]# ll /usr/bin/ |grep python
-rwxr-xr-x  1 root root      11240 Apr  2  2020 abrt-action-analyze-python
lrwxrwxrwx  1 root root         29 Nov 14 01:04 pip3 -> /usr/local/python3/bin/pip3.9
lrwxrwxrwx  1 root root          7 Sep  3 11:48 python -> python2
lrwxrwxrwx  1 root root          9 Sep  3 11:48 python2 -> python2.7
-rwxr-xr-x  1 root root       7144 Apr  2  2020 python2.7
lrwxrwxrwx  1 root root         32 Nov 14 01:04 python3 -> /usr/local/python3/bin/python3.9
[root@centos-moxc bin]# ll /usr/bin/ |grep pip
-rwxr-xr-x. 1 root root       2291 Jul 31  2015 lesspipe.sh
lrwxrwxrwx  1 root root         29 Nov 14 01:04 pip3 -> /usr/local/python3/bin/pip3.9
Licensed under CC BY-NC-SA 4.0
最后更新于 Jan 06, 2025 05:52 UTC
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计
Caret Up