centos下保留python2安装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

 

2.在python官网找到自己需要的python,tar包下载至本地

# wget https://www.python.org/ftp/python/3.A.B/Python-3.A.B.tgz

 

3. 创建Python3的目录

# mkdir /usr/local/python3 

 

4. 解压下载文件并切换目录

# tar -zxvf Python-3.A.B.tgz

# cd Python-3.A.B

 

5. 执行

# ./configure --prefix=/usr/local/python3

# make && make install

 

6. 创建Python3的软链接

# ln -s /usr/local/python3/bin/python3 /usr/bin/python3

 

7. 创建Pip3的软链接

# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

 

8. 测试命令 python3 和 pip3

# python3

# pip3

 

安装保留了原python命令调用python2

安装完成

Ubuntu16.04安装python:https://blog.csdn.net/lzzyok/article/details/77413968

Ubuntu16.04自带python3.5, 安装3.6可能会出现缺失包,依赖环境等问题,可以采用编译安装的方式

centos下保留python2安装python3

centos下保留python2安装python3

 

上一篇:python2和python3的区别


下一篇:关于python中hex转float的问题