Centos7.3安装Python3的方法
查看centos7自带的Python
centos7原本就安装了Python2,而且这个Python2不能被删除,因为有很多系统命令,比如yum都要用到。
[root@zhj]# python`在这里插入代码片`
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
输入Python命令,查看可以得知是Python2.7.5版本
which python :可以查看位置,一般是位于/usr/bin/python目录
安装Python3的方法
1.安装依赖包
yum -y groupinstall "Development tools"
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
2.下载Python3,版本可以自己选择
wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
3.新建存储位置,并解压
mkdir /usr/local/python3
tar -xvJf Python-3.6.2.tar.xz
cd Python-3.6.2
./configure --prefix=/usr/local/python3
make && make install
4.创建软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
5.安装完成```