Centos 6 安裝Python3

 centos6.9python

查看當前版本linux

[root@VM_0_15_centos ~]# python -V
Python 2.6
[root@VM_0_15_centos ~]# which python
/usr/local/bin/python

安裝相關軟件sql

 yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

官網下載Py 3.6.6vim

[root@VM_0_15_centos ~]# wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz

 解壓安裝centos

[root@VM_0_15_centos ~]# tar xf Python-3.6.6.tgz
[root@VM_0_15_centos ~]# cd Python-3.6.6
[root@VM_0_15_centos Python-3.6.6]# ./configure
[root@VM_0_15_centos Python-3.6.6]# make && make install

如今有Python3了ui

[root@VM_0_15_centos ~]# python3
Python 3.6.6 (default, Oct 18 2018, 16:08:12) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()

能夠把原來的軟連接改個名, 新建指向Python3的軟鏈接spa

cd /usr/local/bin/       ###這個路徑是 which python 的結果路徑
mv python python-2
ln -s   /usr/local/bin/python3  python
[root@VM_0_15_centos bin]# python
Python 3.6.6 (default, Oct 18 2018, 16:08:12) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()

由於yum須要執行python2腳本,因此還要修改yum的配置code

[root@VM_0_15_centos bin]# vim /usr/bin/yum
  
#!/usr/bin/python2.6
相關文章
相關標籤/搜索