jupyter中添加conda環(huán)境

1、背景

安裝完Anaconda利用conda創(chuàng)建了虛擬環(huán)境,但是啟動(dòng)jupyter notebook之后卻找不到虛擬環(huán)境。

2、原因

由于在虛擬環(huán)境下缺少kernel.json文件。

3、解決方式

第一步 創(chuàng)建kernel文件

(1)創(chuàng)建環(huán)境時(shí)直接加入ipykernel

conda create -n 環(huán)境名稱 python=3.6 ipykernel

(2)創(chuàng)建環(huán)境時(shí)不安裝ipykernel,那么在虛擬環(huán)境下創(chuàng)建kernel文件

激活conda環(huán)境:

 source activate 環(huán)境名稱

在虛擬環(huán)境下創(chuàng)建kernel文件:

conda install -n 環(huán)境名稱 ipykernel 

第二步 將環(huán)境寫入notebook的kernel中

python -m ipykernel install --user --name 環(huán)境名稱 --display-name "環(huán)境名稱" 
(一定要先激活環(huán)境,然后在將環(huán)境寫入jupyter notebook)

第三步

打開notebook服務(wù)器:

jupyter notebook 

瀏覽器打開對(duì)應(yīng)地址,新建python,就會(huì)有對(duì)應(yīng)的環(huán)境提示了

刪除kernel環(huán)境:

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

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

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