Use Anaconda to create a virtual environment and add it to the Jupyter notebook kernel

1. Modify the storage location of the virtual environment (optional)

Windows: Open the file C:\Users\DongZhaoCheng(对应到你本人的用户名)\.condarc, add envs_dirs: [D:\003SoftDevTool\anaconda_env](对应到你自己执行的目录), save and exit

insert image description here

2. Enter the system terminal to create a virtual environment

Windows:

conda env list: View the list of currently owned conda environments

conda create -n env_py38_jupyter python=3.8: Create a virtual environment with the name and the version env_py38_jupyterof the interpreter usedpython3.8

createWhen the command is in use, please close vpnthe circumvention proxy

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-iJ70rJAI-1690376465586) (C:\Users\DongZhaoCheng\AppData\Roaming\Typora\typora-user-images\ image-20230723171621739.png)]

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-TviTqV7L-1690376465588) (C:\Users\DongZhaoCheng\AppData\Roaming\Typora\typora-user-images\ image-20230723171700091.png)]

3. Enter Anaconda promptthe command window

Anaconda promptWindows: Execute the following commands in sequence

activate env_py39_jupyter: Activate the virtual environment

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ipykernel: Install the kernel

python -m ipykernel install --user --name Python39 --display-name "Python 39": Write the kernel of the current Python environment to the kernel of Jupyter

A successful result looks like this:

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-wrsNw7CX-1690376465589) (C:\Users\DongZhaoCheng\AppData\Roaming\Typora\typora-user-images\ image-20230723172140935.png)]

4. Go back to the normal terminal and open the Jupyter notebook

Excuting an order:jupyter notebook

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-QZ37xQef-1690376465591) (C:\Users\DongZhaoCheng\AppData\Roaming\Typora\typora-user-images\ image-20230723172324005.png)]


If this article is useful to you, you can like and bookmark this article. It will be much easier to find next time you use it. It would be great
if you can follow the author. The author will continue to learn, output, and share! Thank you for your encouragement!

Guess you like

Origin blog.csdn.net/qq_40459977/article/details/131947671