Try   HackMD

設定 Python 路徑

作者:王一哲
日期:2019/7/11


前言

當我們在 Windows 中安裝 Python 時,如果沒有勾選安裝視窗中最下方的選項Add Python 3.6 to PATH,在安裝之後系統會不知道要從什麼地方找到 Python 指令,也就無法指令介面執行 Python。這時我們需要自行修改 Windows 的環境變數 PATH,以下是修改的步驟。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Python 3.6.4 安裝視窗

Windows 7

  1. 在桌面上的電腦按滑鼠右鍵叫出快速選單,點擊最下方的內容

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  2. 點擊左側的第4個項目進階系統設定

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  3. 點擊進階分頁下方的環境變數

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  4. 從下方的系統變數中找到Path,雙擊滑鼠左鍵編輯Path。

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  5. 由於 Windows 7 當中系統變數的變數值會擠在同一格當中,在修改前最好從頭到尾檢查一下裡面是否已經設定了 Python 的路徑,如果沒有的話在這格的最後面加上

    ​​​​C:\Program Files\Python36\Scripts\;C:\Program Files\Python36\
    

    不同的路徑之間以分號隔開。如果安裝的 Python 版本不同,假設安裝 3.7 版,則將路徑中的 Python36 改成 Python37 即可。

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  6. 開啟指令界面,輸入

    ​​​​python --version
    

    如果會顯示已安裝的 Python 版本就成功了。

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

Windows 10

  1. 從左下角的開始選單搜尋環境變數,選取搜尋結果中的編輯系統環境變數

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  2. 點擊進階分頁下方的環境變數

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  3. 從下方的系統變數中找到Path,雙擊滑鼠左鍵編輯Path。

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  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\
    

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  1. 開啟指令界面,輸入
    ​​​​python --version
    
    如果會顯示已安裝的 Python 版本就成功了。


tags:PythonVPython