Linux安装Python3

Posted lichenglong521

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux安装Python3相关的知识,希望对你有一定的参考价值。

1.安装依赖环境
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 gcc
2.下载Python3
wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
3.安装python3
创建目录:

mkdir -p /usr/local/python3
解压下载好的Python-3.x.x.tgz包:
tar -zxvf Python-3.8.2.tgz
4.进入解压后的目录,编译安装。
cd Python-3.8.2
./configure --prefix=/usr/local/python3 && make && make install
5.建立python3的软链
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
6.并将/usr/local/python3/bin加入PATH
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
export PATH
source ~/.bash_profile
7.检查Python3及pip3是否正常可用:
python3 -V
Python 3.8.2

pip3 -V
pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)

以上是关于Linux安装Python3的主要内容,如果未能解决你的问题,请参考以下文章

Linux安装python3.6.2

Linux 安装 python3.6

Linux(Centos)下安装python3

linux环境快速安装python3

linux安装Python3并与系统自带的Python2并存

Linux安装python3.6