Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Interpreter in Jupyter notebook

I am trying to change the interpreter path of my Jupyter notebook environment to the interpreter path I am using with PyCharm.

When I execute the following code with Jupyter notebook I am getting the python installation within the Anaconda main folder and not the one I am using with PyCharm.

import sys
print(sys.executable)

With which command I can change the path to the other python installation I am using with PyCharm?

like image 392
PyPip Avatar asked Oct 31 '19 14:10

PyPip


People also ask

How do I change the interpreter in Python Jupyter lab?

To open the server settings, select Configure Jupyter Server in the list of the Jupyter servers. Configure the server options: To customize the default Jupyter server, in the Jupyter Server dialog, select Managed Server and from the Python interpreter list select any local Python interpreter.

How do you select an interpreter in Jupyter Notebook?

Setting up your environment To work with Python in Jupyter Notebooks, you must activate an Anaconda environment in VS Code, or another Python environment in which you've installed the Jupyter package. To select an environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).

Which interpreter does Jupyter Notebook use?

Language of choice Jupyter supports over 40 programming languages, including Python, R, Julia, and Scala.

How do I change the env on a Jupyter Notebook?

With a new Jupyter notebook open, you can click Kernel > Change kernel > and select the virtual environment you need. I hope this was helpful!


1 Answers

I believe what you are looking for is how to change the Kernel you are running. If you go to the Kernel menu in Jupyter, you will see the option to change kernels.

enter image description here

If you want to add a new kernel from a conda environment, terminate jupyter, activate the environment you want to add a kernel for, and then run this command (requires conda install ipykernel -- thx @shad):

python -m ipykernel install --user --name <kernel_name> --display-name "<Name_to_display>"

Make sure to replace <kernel_name> and <Name_to_display> to the name of your environment. Also, this requires you to conda install ipykernel (thanks @shad).

Once you installed the kernel, you can change to it through the above menu and even through this code snippet from a Jupyter cell:

%%javascript
Jupyter.notebook.session.restart({kernel_name: '<kernel_name>'})
like image 140
Daniel Schneider Avatar answered Sep 21 '22 00:09

Daniel Schneider