Try   HackMD

Python:安裝 python 並且添加環境變數

之前都是用 Anaconda 裡的 Spyder 跟 Jupyter Notebook 編譯 python,但 Anaconda 實在太過於佔用空間最後還是刪除了,改裝 VSCode(VS code 與 wsl 安裝教學)。

Download Python 下載並安裝

Python 官方載點:https://www.python.org/downloads/

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 →

選中你要的版本然後按 download 會跳進下一個頁面,找到符合你作業系統的版本然後按下去就可以下載了。我是下載 64 位元的 Windows Installer 版本。

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 →

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.10 在這個路徑上:

C:\Users\user\AppData\Local\Programs\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 →

添加 Python 路徑到環境變數 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 →

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 →

選中系統變數的 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 的路徑位置如下

C:\Users\user\AppData\Local\Programs\Python\Python310
C:\Users\user\AppData\Local\Programs\Python\Python310\Scripts

把這兩行路徑分別新增加入環境變數裡頭。

要看你的 python 安裝在哪裡,我的筆電預設是安裝在 Users 資料夾當中的 Local Programs,每台電腦安裝路徑並不完全相同。

測試:在 cmd 輸入 python

打開命令提示字元直接輸入 python,出現以下畫面代表安裝跟添加 python 執行路徑到環境變數是成功的了,以後就可以直接在 cmd 執行 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 →

可能碰上的問題:cmd 執行 python 跑出 Microsoft Store

相關文章:如何解決 cmd 執行 python 跑出 Microsoft Store

之前安裝好 python 並且確定有添加環境變數,但在命令提示字元裡執行 python 會一直跳轉到微軟商店,原因是 win10 有個奇怪的應用程式執行別名功能,輸入 python 或是 python3 就會自動幫你打開 Microsoft Store,無論有沒有安裝 python 都會莫名其妙自動導向。

解決辦法是打開設定,也可以直接在工具列上的搜尋上查找管理應用程式執行別名,把「應用程式執行別名」的 App Installer 功能關閉,就不會再自動跳轉了。

設定 > 應用程式與功能 > 應用程式執行別名

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 →

把 App installer (python.exe) 關閉

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 →


: : 20211115 : : 與松 withhhsong : :

tags: notes python withhhsong tutorials