How to use my PyCharm Python Interpreter in Jupyter Notebook?

Viewed 492

Is it possible to use the Python interpreter that I have been using in PyCharm in Jupyter Notebook? I'm not looking to create a brand new virtual environment as I have tried that and encountered "Solving Environment" issues when trying to install packages. How do I get Jupyter Notebook to use my current interpreter ~/opt/anaconda3/envs/PopulationDensity/bin/python as the interpreter?

I have also tried python -m ipykernel install --user --name <kernel_name> --display-name "<Name_to_display>" as suggested in another thread and substituted <kernel_name> with my interpreter path, but that resulted in a syntax error.

1 Answers

The simplest solution is to install Jupyter notebook in the interpreter that Pycharm happens to use and invoke Jupyter notebook from there.

As Pycharm creates new virtual environments for your projects(by default settings), you need to first activate that interpreter.

The Jupyter notebook invoked like above has access to all packages that Pycharm has access to.

Open up a terminal, active the venv and then:

pip install notebook
jupyter notebook

In every running Python you can check the interpreter path with:

import sys
print(sys.executable)
Related