linux系统下安装python 3.9详细教程

x33g5p2x  于2021-10-06 转载在 Linux  
字(1.2k)|赞(0)|评价(0)|浏览(587)

一、查看本机是否安装python 

[root@localhost ~]# python

二、下载python的依赖包

#切换至/usr/local/目录下
[root@localhost ~]# cd /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ls
bin  etc  games  include  lib  lib64  libexec  sbin  share  src

#下载依赖包
[root@localhost local]# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel

三、下载安装包

# 官方地址
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
# 国内镜像
wget http://npm.taobao.org/mirrors/python/3.9.0/Python-3.9.0.tgz
[root@localhost local]# wget http://npm.taobao.org/mirrors/python/3.9.0/Python-3.9.0.tgz

四、解压到对应路径并安装

# 解压压缩包
tar -zxvf Python-3.9.0.tgz  

# 进入文件夹
cd Python-3.9.0

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

# 安装
make && make install

五、添加软链接并查看(类似于window电脑的快捷方式)

[root@localhost local]# ln -s /usr/local/python3/bin/python3.9 /usr/bin/python3.9
[root@localhost local]# ln -s /usr/local/python3/bin/pip3.9 /usr/bin/pip3.9
[root@localhost local]# python3.9 -V
Python 3.9.0

六、使用 python 3.9

[root@localhost local]# python3.9 
Python 3.9.0 (default, Oct  6 2021, 11:22:19) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print ("hell0 word!")
hell0 word!
>>>

相关文章