Use of jupyter in Ubuntu (stepping on the pit)

Question 1: In the use of Jupyter, the package has been installed in the environment, but the import package reports an error No module named 'torch' or other package names

        The reason is that the virtual environment established by conda is not used correctly

        Just add the established virtual environment to jupyter:

python -m ipykernel install --user --name AI_3.8 --display-name "Python AI_3.8"

        View kernel commands

jupyter kernelspec list

        Uninstall the specified kernel command (kernel_name is the name of the kernel to be uninstalled)

jupyter kernelspec remove kernel_name

Question 2: How to change the default opening path

        Just installed jupyter default directory is the user directory

        Step1 generate configuration file

jupyter notebook --generate-config

        Step2 Open the file with vim

vim .jupyter/jupyter_notebook_config.py

        Step3 Find the location of the configuration default directory

                Do not press i to enter insert mode, enter /notebook.dir to find the corresponding location

        Step4 delete the comment symbol in front of the new line

        Step5 Modify the path to the path you need, then exit and save

Question 3 How to automatically load the conda virtual environment to the jupyter kernel

(base)$ conda install nb_conda_kernels

(base)$ conda create --name new-env

(base)$ conda activate new-env

(new-env)$ conda install ipykernel

Guess you like

Origin blog.csdn.net/qsdftuyiop/article/details/129987620