標籤: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簡介與安裝