Notebook Pycharm Jupyter `PYTHONPATH`?

System Information

  • Mac OS X 10.12 Sierra
  • Pycharm 2016.2.3
  • Python 3.5.1
  • Jupyter 4.1.0

Question

When I use the Jupyter Notebook under Pycharm, it does not seem to include my current working directory or source root directory in the PYTHONPATH currently active Jupyter Notebook. This is not like the behavior of regular .py files, for which Pycharm automatically includes the current directory and the root directory of the project source code in PYTHONPATH . So, is it possible to install Pycharm to automatically include the root directory of the project source code in PYTHONPATH for Jupyter laptops running Pycharm?

+8
source share
3 answers

Pycharm 2019.1 has completely updated support for Jupyter. Jetbrains says this about Pycharm 2019.1: "PyCharm's Jupyter Notebook support has been redesigned from scratch."

So, starting with Pycharm 2019.1, now you can configure Pycharm to include the source root of the project directory for Jupyter laptops.

See this Pycharm 2019.1 help page.

0
source

There are many ways to communicate with the environment, but a special way for PyCharm to work for me was to make the directory with my source in it the β€œroot source” of PyCharm, as described here: https://www.jetbrains.com/ help/PyCharm/content-root .html

This can be done from the catalog context menu in the navigator or from the "Project structure" settings panel.

This seems to update PYTHONPATH as well as sort things like autocomplete.

0
source

It turns out that in past efforts I modified my jupyter_notebook_config.py in the %USER%\.jupyter . Look at the lines as follows:

 ## The directory to use for notebooks and kernels. c.NotebookApp.notebook_dir = 'D:\\Works\\GitHub\\Jupyter\\' 

The line under ## , obviously, indicates the path of redefinition.

When I commented it out ... Suddenly Pycharm started successfully with a pwd file (.ipynb location). good luck xxx

0
source

Source: https://habr.com/ru/post/1257960/


All Articles