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虛擬環境-建議一專案一個虛擬環境
請先確定 apt 已更新至最新
sudo apt update -y
sudo apt upgrade - y
-
新增虛擬環境 : python3 -m venv myproject
(myproject:專案名稱可換成你要的名稱)
-
cd myproject
-
啟動虛擬環境: source bin/activate
離開虛擬環境: deactivate
-
查看已安裝模組: pip list (這時候環境很單純沒有不必要的模組)
- pip升級到最新版: pip install –upgrade pip
- mkdir app :把程式.py放在這個目錄裡並在這個目錄中新增requirements.txt
填入你會用到的模組,例如 fastapi,line-bit-sdk,
pip install -r requirements.txt (會自動安裝相依的模組)
也可以用指令 pip freeze > requirements.txt 將你會用到的模組寫進 requirements.txt中
,未來移植專案時就能直接下指令
pip install -r requirements.txt
一鍵安裝所有的模組且不會有版本不合的問題。
或者可以安裝package,以安裝jupyter notebook為例
例如:pip install notebook
執行 jupyter notebook
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 入門教學Author