Recently, I started to create a virtual environment in Anaconda and code it in an environment that suits my purpose. Among them, for some reason only one of the PCs I own was able to select the kernel from Jupyter Notebook without any settings, but on other PCs I select the kernel without settings. I couldn't. (Probably a problem with the version of Anaconda.) So, I did a lot of research on the net so that I could select the kernel from Jupyter Notebook. However, in my environment (because it is Windows), including Additional packages did not work, or the command information was out of date, so I used it for myself. I will summarize it in. With this setting, you can change the kernel in an instant as follows!
You can easily create a virtual environment by using conda. This time, it is assumed that jupyter will be used, so install jupyter at the same time when creating this virtual environment.
create_env
#Create virtual environment, install jupyter
$ conda create --name=test python=python3.6 jupyter
#Check if the virtual environment is created, if it is displayed in the list, it is successful
$ conda info -e
Enter the appropriate python version and --name =
At this stage, I don't think the kernel has been added yet. Now try running the following command:
check_kernel
#View available kernels
$ jupyter kernelspec list
Add the kernel of the virtual environment you added earlier here. Execute the following command with the virtual environment activated.
install_kernel
#Activate virtual environment
$ activate test
#Add kernel
$ ipython kernel install --user --name=test --display-name=test
Now you can switch and select kernels on Jupyter Notebook.
Finally, I will summarize the main options when adding a kernel.
option | role |
---|---|
-h, --help | Get help on options |
--user | Installed for currently logged in user |
--name NAME | Specify the name of the kernel spec When specifying multiple IPython kernelsMandatory |
--display-name DISPLAY_NAME | Specify the name of the displayed kernel |
The added kernel information is located in ~ \ AppData \ Roaming \ jupyter \ kernels with the --user option. You can remove the added kernel by deleting the folder with the name specified by --name here.
You can also remove the kernel with the following command.
uninstall_kernel
#Remove kernel
$ jupyter kernelspec uninstall test
Recommended Posts