Jupyter notebook file directory not in working directory

The problem has been posted here, but I am not sure if it has been solved yet, and what the solution is:

https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000551684-Jupyter-Notebook-default-working-directory?sort_by=created_at

The problem with PyCharm is it does not add the folder in which the notebook belongs to to the working directory. PyCharm only adds the project root.

Example:

Pycharm opens D:\myproject

Jupyter notebook is located at D:\myproject\notes\note1.ipynb

When running note1.ipynb,

In Pycharm, print(sys.path) >> D:\myproject

In localhost:8888, print(sys.path) >> D:\myproject\notes

I can manually add path for every notebook file, but it is incredibly annoying. I want PyCharm to automatically add X:\the\directory\of\the\notebook\ to PATH, like how jupyter server does.

I am using 2020.2 Professional, if that matters. Thanks for the help.

0

Please sign in to leave a comment.