LINUX安装PYTHON3.7.2详细操作步骤

1.下载Python依赖环境

yum install 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 -y

2.安装wget

[root@localhost ~]# yum install wget -y

3.下载python3.7.2源码包到opt文件夹下面

[root@localhost ~]# wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz

4.解压下载好的Python安装包

[root@localhost opt]# tar -zxvf Python-3.7.2.tgz

5.进入解压后的目录,编译安装

[root@localhost opt]# cd Python-3.7.2
[root@localhost Python-3.7.2]# ./configure --prefix=/opt/python37
[root@localhost Python-3.7.2]# make && make install

6.建立Python3的软连接

# python3.7.3软链接
[root@localhost bin]# ln -s /opt/python37/bin/python3 /usr/bin/python3
# pip3软链接
[root@localhost ~]# ln -s /opt/python37/bin/pip3 /usr/bin/pip

7.将环境变量路径写入文件

复制代码
[root@localhost ~]# vi .bash_profile 
[root@localhost ~]# source ~/.bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/bin/python3/bin

export PATH

也可以下载etc/profile文件
[root@localhost conf]# cat /etc/profile
PATH=/opt/python37/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
复制代码

8.输入python3出现这个,表示安装成功了!

posted on 2020-12-11 14:00  gdg87813  阅读(502)  评论(0编辑  收藏  举报

导航