如何在Python中建立虛擬環境

閱讀本文前請先安裝Anaconda

建立資料夾

mkdir django-app
cd django-app

建立虛擬環境

#升級conda
conda update conda
#建立envName為名,python版本3.6的虛擬環境

conda create -n envName python=3.6
#啟動envName的虛擬環境
activate envName
#停止虛擬環境
conda deactivate
#顯示所有虛擬環境(兩指令功能一樣)
conda env list
conda info -e
#刪除虛擬環境
conda remove -n envName --all
#複製一個與現有電腦環境一樣的虛擬環境
conda create -n envName --clone root

安裝需要的套件

pip install packageName或者pip install -r requirements.txt  #requirements.txt可參考Python:一鍵匯出專案所需模組清單

進行開發

Machine Learning / Deep Learning / Python / Flutter cakeresume.com/yanwei-liu

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store