当前位置: > Linux教程 > Linux学习 >

Linux下快速安装Python

时间:2020-04-11 18:25来源:linux.it.net.cn 作者:IT
1.1.下载python3源码包
wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz

2下载python3编译的依赖包
yum install -y gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

3.tar -zxvf Python-3.6.6.tgz

4.进入源码包文件夹
cd Python-3.6.6

5.编译且安装
./configure --prefix=/opt/python36 # 指定安装目录为/opt/python36

make && make install # 先进行make,执行完成之后,才开始执行make install

6.更改linux的path变量,添加python3
vim /etc/profile
PATH=/data/python36/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

为了永久生效path设置,添加到/etc/profile全局环境变量配置文件中 ​ 重载配置文件/etc/profile
source /etc/profile


8.进入pyhon3 命令行直接输入python3回车


(责任编辑:IT)
------分隔线----------------------------