“This is the 30th day of my participation in the First Challenge 2022. For details: First Challenge 2022.”
Introduction:
Jupyter Lab is a Python IDE that is powerful and easy to debug. When using Jupyter Lab, you need to set up the default interpreter for running the script first. This blog recorded how to set up multiple interpreters in the jupyter Lab free switching method and the process of pit.
Problem description
I installed several Conda environments on the server side, but when I opened Jupyter Lab and selected the interpreter path configuration, it showed that there was only one interpreter. However, when you open the jupyter script on the VScode compiler, you are free to switch and choose the python interpreter to use.
This interpreter is not the interpreter for my Conda base environment, nor for any other Conda virtual environment. As a result, it is cumbersome to reinstall packages when some code is run.
Problem solving
According to the information found on the Internet, the ipykernel package can be installed to manage (that is, add and delete) various Python interpreters in Jupyter Lab. The configuration is then done. Related methods are recorded as follows:
Add a kernel using the ipykernel package
First, we need to activate the Conda environment for the interpreter we are adding.
conda activate picard
Copy the code
Then, install the ipykernel package using Conda.
conda install ipykernel
Copy the code
After installation, use the following commands to add the interpreter of the current environment to JUPyter Lab.
python -m ipykernel install --name picard
Copy the code
After I follow the above steps, an error occurs as follows:
[13] Errno Permission denied: '/ usr/local/share/jupyter'Copy the code
Here, if we do not want to modify the system’s Jupyetr configuration, we should only change the jupyter Lab configuration in our user directory. The solution is simple, simply add “–user” after the command.
After the previous modification, the data is added successfully.
(base) jxqi@server2:~$ conda activate picard
(picard) jxqi@server2:~$ python -m ipykernel install --user --name picard
Installed kernelspec picard in /home/jxqi/.local/share/jupyter/kernels/picard
Copy the code
The added interpreter can also be seen in jupyter Lab.
reference
- [Errno 13] Permission denied: ‘/usr/local/share/jupyter’, blog.csdn.net/qq_33919727…