虛擬環境下創建jupyter內核
1.激活虛擬環境 :activate pytorch
2.在cmd中檢查jupyter是否已經被安裝:conda list
如果可以找到“jupyter”,說明已經被安裝。否則使用一下命令進行安裝。
3.安裝jupyter:conda install jupyter
4.安裝ipykernel
conda deactivate ##退出當前虛擬環境
conda install ipykernel ##安裝ipykernel
5. 進入已建虛擬環境中安裝ipykernel
輸入以下命令進入已建的虛擬環境,並安裝ipykernel。
1 activate pytorch ##進入已建虛擬環境(名稱根據實際情況進行修改) 2 3 python -m ipykernel install --user --name pytorch --display-name "Python(pytorch)"
##pytorch是指已建環境名; Python(pytorch)是指想要在jupyter notebook中顯示的名字
發生dead kernel 問題:
- 首先使用jupyter kernelspec list查看安裝的內核和位置
- 進入安裝內核目錄打開kernel.jason文件,查看Python編譯器的路徑
- 如果不正確修改為正確的安裝路徑
- 重啟 jupyter notebook:
jupyter notebook
若是路徑正確:則在進入jupyter notebook之前先激活虛擬環境,之后再進入jupyter notebook就不會發生內核死亡問題