CentOS 7下安装Python3.6

1)安装python3.6可能使用的依赖
yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

2)到python官网找到下载路径, 用wget下载
wget --no-check-certificate https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz

3)解压tgz包
tar zxvf Python-3.6.5.tgz

4)/usr/local下面新建python3目录
cd /usr/local/
mkdir python3

5)编译python3
cd Python-3.6.5/
./configure --prefix=/usr/local/python3/

6)安装python3
make && make install

7)修改原来2.7.5的python文件名
mv /usr/bin/python /usr/local/python_old

8)新建连接到python3.6.5
ln -s /usr/local/bin/python3.6 /usr/bin/python

#9)其他问题
vim /usr/bin/yum
将#!/usr/bin/python
改为:
#!/usr/bin/python2

vim /usr/libexec/urlgrabber-ext-down
将#!/usr/bin/python
改为:
#!/usr/bin/python2

10)查看版本
python -V

 

posted on 2018-06-17 14:34  新美好时代  阅读(116)  评论(0编辑  收藏  举报