# 設定 Python 路徑
> 作者:王一哲
> 日期:2019/7/11
<br />
## 前言
當我們在 Windows 中安裝 Python 時,如果沒有勾選安裝視窗中最下方的選項**Add Python 3.6 to PATH**,在安裝之後系統會不知道要從什麼地方找到 Python 指令,也就無法指令介面執行 Python。這時我們需要自行修改 Windows 的環境變數 **PATH**,以下是修改的步驟。
<img style="display: block; margin-left: auto; margin-right: auto" height="80%" width="80%" src="https://i.imgur.com/KHXTiS1.png">
<div style="text-align:center">Python 3.6.4 安裝視窗</div><br />
## Windows 7
1. 在桌面上的**電腦**按滑鼠右鍵叫出快速選單,點擊最下方的**內容**。
<img style="display: block; margin-left: auto; margin-right: auto" height="50%" width="50%" src="https://imgur.com/CE8npdm.png"><br />
2. 點擊左側的第4個項目**進階系統設定**。
<img style="display: block; margin-left: auto; margin-right: auto" height="100%" width="100%" src="https://imgur.com/yCR1eRF.png"><br />
3. 點擊**進階**分頁下方的**環境變數**。
<img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/ghqGaOn.png"><br />
4. 從下方的**系統變數**中找到**Path**,雙擊滑鼠左鍵編輯Path。
<img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/wdbcjwh.png"><br />
5. 由於 Windows 7 當中系統變數的變數值會擠在同一格當中,在修改前最好從頭到尾檢查一下裡面是否已經設定了 Python 的路徑,如果沒有的話在這格的最後面加上
```
C:\Program Files\Python36\Scripts\;C:\Program Files\Python36\
```
不同的路徑之間以分號隔開。如果安裝的 Python 版本不同,假設安裝 3.7 版,則將路徑中的 **Python36** 改成 **Python37** 即可。
<img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/t9ZoAVU.png"><br />
6. 開啟指令界面,輸入
```shell
python --version
```
如果會顯示已安裝的 Python 版本就成功了。
<img style="display: block; margin-left: auto; margin-right: auto" height="80%" width="80%" src="https://imgur.com/TrN46WJ.png"><br />
## Windows 10
1. 從左下角的開始選單搜尋**環境變數**,選取搜尋結果中的**編輯系統環境變數**。
<img style="display: block; margin-left: auto; margin-right: auto" height="50%" width="50%" src="https://imgur.com/jwjREeH.png"><br />
2. 點擊**進階**分頁下方的**環境變數**。
<img style="display: block; margin-left: auto; margin-right: auto" height="80%" width="80%" src="https://imgur.com/5nScDnc.png"><br />
3. 從下方的**系統變數**中找到**Path**,雙擊滑鼠左鍵編輯Path。
<img style="display: block; margin-left: auto; margin-right: auto" height="80%" width="80%" src="https://imgur.com/fwGli0d.png"><br />
4. Windows 10 當中系統變數的變數值不會擠在一起,點擊右上方的**新增**,加入以下兩個路徑。
```
C:\Program Files\Python36\Scripts\
C:\Program Files\Python36\
```
如果安裝的 Python 版本不同,假設安裝 3.7 版,則將路徑中的 **Python36** 改成 **Python37** 即可。在後來的版本當中,例如 3.9 版,預設的路徑會是
```
C:\Users\[UserName]\AppData\Local\Programs\Python39\Scripts\
C:\Users\[UserName]\AppData\Local\Programs\Python39\
```
<img style="display: block; margin-left: auto; margin-right: auto" height="80%" width="80%" src="https://imgur.com/l1y9nh9.png"><br />
5. 開啟指令界面,輸入
```shell
python --version
```
如果會顯示已安裝的 Python 版本就成功了。
<br />
---
###### tags:`Python`、`VPython`