CentOS7.2下python3.6安装

1、安装python3.6可能使用的依赖

# yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel zlib-devel

2、下载python源码包,地址为https://www.python.org/downloads/

# tar -zxvf Python-3.6.1.tgz
# cd Python-3.6.1/

3、把python3.6安装到/usr/local目录下

# ./configure --prefix=/usr/local/
# make
# make altinstall

4、更改/usr/bin/python链接

# cd /usr/bin
# mv python python.backup
# ln -s /usr/local/bin/python3.6 /usr/bin/python
# ln -s /usr/local/bin/python3.6 /usr/bin/python3
# rm -rf /usr/bin/python2
# ln -s /usr/bin/python2.6 /usr/bin/python2

5、更改yum脚本的python依赖

# cd /usr/bin
# ll yum*
有以下文件:
-rwxr-xr-x 1 root root   802 Jan  2 17:53 yum
-rwxr-xr-x 1 root root  9374 Jan  2 17:53 yum-builddep
-rwxr-xr-x 1 root root  8091 Jan  2 17:53 yum-config-manager
-rwxr-xr-x 1 root root  7610 Jan  2 17:53 yum-debug-dump
-rwxr-xr-x 1 root root  7904 Jan  2 17:54 yum-debug-restore
-rwxr-xr-x 1 root root 10906 Jan  2 17:54 yumdownloader
-rwxr-xr-x 1 root root 11032 Jan  2 17:54 yum-groups-manager
修改以上文件头:

#!/usr/bin/python 改为 #!/usr/bin/python2

CentOS7.2下python3.6安装_第1张图片

如果出现以下报错:File “/usr/libexec/urlgrabber-ext-down”, line 28

vim /usr/libexec/urlgrabber-ext-down

将/usr/bin/python改为/usr/bin/python2即可




你可能感兴趣的:(python)