第四百節,Django+Xadmin打造上線標準的在線教育平臺—生產環境部署CentOS6.5安裝python3.5.1python
1.檢查系統是否安裝了pythonlinux
[root@192 ~]# rpm -qa python python-2.6.6-51.el6.x86_64 [root@192 ~]#
能夠看到CentOS6.5系統默認安裝了python2.6.6vim
2.檢查一下Python安裝在什麼地方ide
[root@192 ~]# whereis python python: /usr/bin/python /usr/bin/python2.6 /usr/lib/python2.6 /usr/lib64/python2.6 /usr/include/python2.6 /usr/share/man/man1/python.1.gz [root@192 ~]#
能夠看到Python啓動文件在/usr/bin/python2.6裏,有一個快速軟鏈接在/usr/bin/python,那麼咱們就要安指定其餘目錄安裝,防止默認安裝到2.6.6的路徑起衝突,2.6.6不能卸載掉,由於系統的yum命令是依賴Python2.6.6的測試
3.安裝依賴庫和編譯器spa
# yum install gcc -y # yum install openssl-devel
若是沒有安裝openssl-devel,在安裝過程當中pip沒法安裝code
4.下載對應版本的Python,並解壓orm
wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz 下載python
tar -xvf Python-3.5.1.tgz 解壓Python
5.進入Python解壓目錄,編譯安裝Python3.5.1blog
cd Python-3.5.1
./configure --prefix=/usr/local 指定編譯安裝的目錄
make && make install 編譯而且安裝到指定目錄
6.檢查一下Python3.5安裝的詳情ip
[root@192 Python-3.5.1]# whereis python python: /usr/bin/python /usr/bin/python2.6 /usr/lib/python2.6 /usr/lib64/python2.6 /usr/local/bin/python3.5-config /usr/local/bin/python3.5m /usr/local/bin/python3.5m-config /usr/local/bin/python3.5 /usr/local/lib/python3.5 /usr/include/python2.6 /usr/share/man/man1/python.1.gz
能夠看到Python3.5.1已經安裝成功
7.將系統默認的python啓動文件修改爲別的名字
修改/usr/bin下的Python文件名字
8.將Python3.5.1安裝目錄下的Python3.5啓動文件建立軟連到,Python默認的啓動目錄
ln -s /usr/local/bin/python3.5 /usr/bin/python 建立Python3.5軟鏈接到/usr/bin/目錄,名字叫Python
9.這樣之後輸入Python回車後就是執行的Python3.5.1的版本
[root@192 /]# python Python 3.5.1 (default, Oct 3 2017, 03:19:49) [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
10.在安裝python3.5.1時自動安裝了pip3,測試一下pip3是否可用
[root@192 /]# pip3 list pip (7.1.2) setuptools (18.2) You are using pip version 7.1.2, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. [root@192 /]#
能夠看到pip3能用
11.修改/usr/bin/yum文件
由於yum命令默認使用的Python文件名稱調用的Python2.6.6,咱們將Python軟鏈接了python3.5.1因此如今yum命令不能夠用了,咱們要改一下yum配置文件,讓它用回python2.6.6版本
vim /usr/bin/yum 將第一行中的「#!/usr/bin/python」 修改成「#!/usr/bin/python-2.6」,保存便可
測試
[root@192 /]# yum Loaded plugins: fastestmirror, refresh-packagekit, security You need to give some command Usage: yum [options] COMMAND
安裝完成