1 python簡介與安裝

來源:互聯網
上載者:User

標籤:python安裝

在學習一門語言之前,咱們先瞭解為什麼我們要學它。


python是一個指令碼語言,語言簡單,相容各版本系統,學習這門語言將對以後的營運日常工作提供極大的便利。


1.1 Linux 下 python 安裝

首先從官網下載所需要的 python 版本,解壓後直接編譯安裝即可,

[[email protected] /]# tar -zxf Python-2.7.11.tgz

[[email protected] /]# cd Python-2.7.11

[[email protected] /]# ./configure && make && make install


然後我們可以在安裝目錄查看到 Python 2.7.11 版本已經安裝

[[email protected] usr]# /usr/local/bin/python

Python 2.7.11 (default, Jan  2 2017, 12:16:39) 

[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> exit()


但是我們系統內建版本為 python 2.6.6,我們如何替換成編譯好的 python 2.7.11 呢

[[email protected] usr]# python

Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22) 

[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> 

>>> exit()


我們先進入系統 python 所在目錄,把開機檔案備份下,然後刪除

[[email protected] usr]# cd ..

[[email protected] /]# cp /usr/bin/python /usr/bin/python.bak.2017

[[email protected] /]# rm /usr/bin/python

rm: remove regular file `/usr/bin/python‘? y


接著我們把編譯好的 python 2.7.11 版本的開機檔案做個軟串連到目前的目錄下,之後我們再查看python 版本時,就變成我們編譯的版本了

[[email protected] /]# ln -s /usr/local/bin/python2.7 /usr/bin/python

[[email protected] /]# python

Python 2.7.11 (default, Jan  2 2017, 12:16:39) 

[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> 

>>> exit()


1.2 Windows 下 python 安裝

從官網下載安裝包添加環境變數即可。


1 python簡介與安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.