Jupyter Notebook switch Python environment

1. Questions

When using Jupyter Notebook to run the code, the default environment is
insert image description here
to click New to see the current environment
insert image description here
In the running interface, click Kernel-Change Kernel to see what
insert image description here
if we want to change the environment? How should it be done?

2. Concrete operation

(1) Open Anaconda Promptand activate the environment you want to join (the environment you want to activate in this article is torch-gpu)

conda activate torch-gpu

insert image description here
(2) Install ipykernel

conda install ipykernel

insert image description here
(3) Introduce the local environment into Jupyter (change the two torch-gpu to the environment you want to activate)

python -m ipykernel install --user --name torch-gpu --display-name“Python [conda env:torch-gpu]”

(4) Click New to view.
insert image description here
Click Kernel-Change Kernel on the running interface to view
the change successfully!

Guess you like

Origin blog.csdn.net/weixin_45913084/article/details/129203108