python--linux安裝

來源:互聯網
上載者:User

標籤:span   升級版本   nod   efi   sep   strong   misc   value   linu   

centos7

查看預設Python版本內建2.7.5版本

[[email protected] ~]# cat /etc/redhat-releaseCentOS Linux release 7.3.1611 (Core)[[email protected]-node1 ~]# python -VPython 2.7.5
升級版本-3.x1、安裝gcc,用於編譯Python源碼
[[email protected] ~]# yum install gcc
 2、下載源碼包

 官網下載:https://www.python.org/ftp/python/

3、解壓並進入源碼檔案
[[email protected] ~]# lltotal 14468-rw-------. 1 root root     1208 Dec 15  2016 anaconda-ks.cfg-rw-r--r--  1 root root 14808460 Apr 20 15:47 Python-3.5.0.tar.xz[[email protected]-node1 ~]# tar xf Python-3.5.0.tar.xz[[email protected]-node1 ~]# cd Python-3.5.0/[[email protected]-node1 Python-3.5.0]# lltotal 980-rw-r--r--  1 1000 1000   8466 Sep 13  2015 aclocal.m4-rwxr-xr-x  1 1000 1000  42856 Sep 13  2015 config.guess-rwxr-xr-x  1 1000 1000  35740 Sep 13  2015 config.sub-rwxr-xr-x  1 1000 1000 464952 Sep 13  2015 configure-rw-r--r--  1 1000 1000 150676 Sep 13  2015 configure.acdrwxrwxr-x 18 1000 1000   4096 Sep 13  2015 Docdrwxrwxr-x  2 1000 1000     20 Sep 13  2015 Grammardrwxrwxr-x  2 1000 1000   4096 Sep 13  2015 Include-rwxr-xr-x  1 1000 1000   7122 Sep 13  2015 install-shdrwxrwxr-x 46 1000 1000   8192 Sep 13  2015 Lib-rw-r--r--  1 1000 1000  12761 Sep 13  2015 LICENSEdrwxrwxr-x  8 1000 1000    151 Sep 13  2015 Mac-rw-r--r--  1 1000 1000  56690 Sep 13  2015 Makefile.pre.indrwxrwxr-x  2 1000 1000   4096 Sep 13  2015 Miscdrwxrwxr-x 11 1000 1000   4096 Sep 13  2015 Modulesdrwxrwxr-x  4 1000 1000   4096 Sep 13  2015 Objectsdrwxrwxr-x  2 1000 1000   4096 Sep 13  2015 Parserdrwxrwxr-x  6 1000 1000   4096 Sep 13  2015 PCdrwxrwxr-x  2 1000 1000   4096 Sep 13  2015 PCbuilddrwxrwxr-x  2 1000 1000     79 Sep 13  2015 Programs-rw-r--r--  1 1000 1000  41790 Sep 13  2015 pyconfig.h.indrwxrwxr-x  3 1000 1000   4096 Sep 13  2015 Python-rw-r--r--  1 1000 1000   6740 Sep 13  2015 README-rw-r--r--  1 1000 1000  98075 Sep 13  2015 setup.pydrwxrwxr-x 22 1000 1000   4096 Sep 13  2015 Tools
4、編譯安裝
[[email protected] Python-3.5.0]# ./configure[[email protected]-node1 Python-3.5.0]# make all[[email protected]-node1 Python-3.5.0]# make install

註:編譯需要等一段時間~

5、查看版本
[[email protected] Python-3.5.0]# /usr/local/bin/python3.5 -VPython 3.5.0
6、修改預設Python版本
[[email protected] Python-3.5.0]# mv /usr/bin/python /usr/bin/python2.7.5         #移走舊版本的python並命名為2.7.5[[email protected]-node1 Python-3.5.0]# ln -s /usr/local/bin/python3.5 /usr/bin/python  #做軟串連[[email protected]-node1 Python-3.5.0]# python -V                                       #驗證預設版本 Python 3.5.0

 

7、防止yum執行異常,修改yum使用的Python版本
[[email protected] Python-3.5.0]# vim /usr/bin/yum    #將頭部 #!/usr/bin/python 修改為 #!/usr/bin/python3.5[[email protected]-node1 Python-3.5.0]# cat /usr/bin/yum#!/usr/bin/python3.5import sys

 

python--linux安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.