Windows 下 使用 Conda 配置多版本 Python 環(huán)境

速記

1. 安裝

Miniconda 是Conda最精簡的版本,為了避免引入大量不必要的庫,這里我們使用Miniconda進(jìn)行安裝。關(guān)于Miniconda介紹如下:

Miniconda installers contain the conda package manager and Python. 
Once Miniconda is installed, you can use the conda command to install any other packages and create environments.

可以看出,一旦我們安裝了Miniconda ,我們就可以為所欲為了。

Miniconda 官方下載地址請點(diǎn)擊這里:Miniconda 官方下載地址,下載之后一路綠燈安裝即可。

如下,官方提供了兩個版本的Installer,我們?nèi)芜x其一安裝即可。

安裝好后,如果想安裝多版本Python,繼續(xù)安裝另一版本即可(下面詳細(xì)介紹)。關(guān)于兩版本安裝先后的區(qū)別如下:

The other difference is that the Python 3 version of Miniconda will default to Python 3 when creating new environments and building packages. 

這里采用首先安裝好Pyhon3后舉例說明如何安裝Python2版本,Cmd 操作如下:

# 安裝 python 2.7
$ conda create -n python2 python=2.7
# 切換至 python 2.7 
$ activate python2
# 退出 python 2.7
$ deactivate
# 安裝第三方包
$ conda install  xxxx

默認(rèn)環(huán)境為 python 3.7 ,Conda 其他常用操作命令請自行百度。

2. 關(guān)于目錄結(jié)構(gòu)簡單介紹
比如我的miniconda安裝目錄在D:\software\miniconda。則:
python3.7 的可執(zhí)行文件位置為:D:\software\miniconda\python.exe
python2.7 的可執(zhí)行文件位置為:D:\software\miniconda\envs\python2\python.exe
構(gòu)建項目時可通過切換可執(zhí)行文件切換python環(huán)境。

通過conda下載的第三方包位置為:
python3.7 :D:\software\miniconda\Lib\site-packages
python2.7 :D:\software\miniconda\envs\python2\Lib\site-packages

是不是很簡單?

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容