CentOS7 下安装python3.7和pip3 并保留系统自带python2.7

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 libffi-devel

 

2. 下载Python3.7的安装包

# wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz

 

3. 创建Python3的目录

# mkdir /usr/local/python3

 

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

# tar -zxvf Python-3.7.0.tgz

# cd Python-3.7.0

 

5. 执行

# ./configure 

 

若出错 可能因为gcc没有安装

yum -y install gcc

yum -y install gcc-c++

 

运行后会提醒

If you want a release build with all stable optimizations active (PGO, etc),
please run ./configure --enable-optimizations

可以运行 ./configure --enable-optimizations 进行配置优化

# make && make install

 

6. 创建软链接

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

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

 

7.测试命令 python3 和 pip3

# python3 -V

# pip3 -V

posted @ 2018-10-23 15:43  小二君i  阅读(4505)  评论(0)    收藏  举报