目錄:
1.Python-解釋器的下載
2.Python-解釋器的安裝
3.Python-解釋器的測試
4.Python的環境變量的配置
(一)Python解釋器的安裝:
2.官網圖片:
![image.png](http://static.javashuo.com/static/loading.gif)
3.下載windows版:
![image.png](http://static.javashuo.com/static/loading.gif)
4.雙擊安裝文件進行安裝:
![image.png](http://static.javashuo.com/static/loading.gif)
5.勾選添加配置路徑並自定安裝;
![image.png](http://static.javashuo.com/static/loading.gif)
6.點擊下一步:
![image.png](http://static.javashuo.com/static/loading.gif)
7.選擇保存路徑:
![image.png](http://static.javashuo.com/static/loading.gif)
8.等待安裝完後點擊關閉便可:
![image.png](http://static.javashuo.com/static/loading.gif)
9.按系統圖標鍵+R,輸入cmd打開控制檯測試是否安裝成功:
![image.png](http://static.javashuo.com/static/loading.gif)
10.在控制檯輸入:python,彈出以下顯示說明安裝成功。
![image.png](http://static.javashuo.com/static/loading.gif)
(二)Python環境配置:
1.若是在安裝的時候,忘記了勾選添加環境,在控制檯輸入python的時候,會提示以下錯誤。(因爲我安裝的有多個版本的Python解釋器,即便去掉了3.7版的解釋器路徑,3.6版的路徑還在,要是輸入的是python的時候,仍是會運行3.6版的python,在這裏暫且用python3來演示吧。)
![image.png](http://static.javashuo.com/static/loading.gif)
2.解決方案:選中個人電腦,右擊點擊屬性,打開環境配置的設置頁面
![2018-10-27_235044.jpg](http://static.javashuo.com/static/loading.gif)
3.選擇高級設置:
![image.png](http://static.javashuo.com/static/loading.gif)
4.點擊環境變量:
![image.png](http://static.javashuo.com/static/loading.gif)
5.選擇Path,點擊編輯(這裏須要咱們添加解釋器的路徑,當咱們在控制檯輸入python的時候,系統才能找到python.exe的可執行文件,並執行它)
![image.png](http://static.javashuo.com/static/loading.gif)
6.在安裝Python的文件夾裏複製路徑:(並看到該文件夾裏面有python.exe文件,.exe格式也就是所謂的可執行文件)
![image.png](http://static.javashuo.com/static/loading.gif)
原理:咱們能夠作個實驗,來驗證在控制檯裏能夠根據路徑找到.exe文件,並在控制檯輸入它的主名(不包括後綴名)時,就能夠運行該程序。
在控制檯跳轉到你要執行的文件的路徑下:(咱們能夠看到,在該文件夾下有python.exe文件,咱們以python3.6所在的路徑爲例,而且執行成功,因此配置環境的做用就是告訴系統,一個全局的路徑,當咱們執行一個可執行文件的時候,系統就會去咱們配置的路徑下去找。可見在控制檯運行exe文件,有兩種方式,一種是跳轉到所要執行的文件路徑下,另外一種即是咱們對Python解釋器採用的配置環境變量。)
![image.png](http://static.javashuo.com/static/loading.gif)
7.粘貼到剛纔編輯打開的Path框內:(而且以英文的分號結尾,與其餘的環境變量隔開)
![image.png](http://static.javashuo.com/static/loading.gif)
注:當你有多個Python解釋器的時候,即多個版本python的時候,在控制檯輸入python時,該執行哪一個解釋器(哪一個python版本)?系統是按照各版本的路徑在Path框裏的前後順序檢索的,也就是說你把那個路徑放在前面,它就先找到那個解釋器,它就先執行那個版本的python解釋器。
8.依次肯定,關閉環境配置的窗口及到控制檯測試:(咱們看到已經運行成功)
![image.png](http://static.javashuo.com/static/loading.gif)
本小節結束!
我是張一根,一個在讀本科的計算機愛好者,期盼和你一塊兒交流計算機的知識,讓咱們在這個大時代裏一塊兒進步。python