How to set working directory for ipython notebook?
Answered
My project structure is as follows:
~/Edu/ML/ -- project root
. . .pyenv -- venv
. . some_course/ -- a course root, there're many of them
. . . work/ -- source root for the course
. . . . blablabla.ipynb -- a notebook i'm intened to work with
The notebook contains statements like `open("some_file")` that suppose files to be found in current working directory. But current working directory is set to project root.
How do i change working directory for this notebook to `~/Edu/ML/acourse/work` ?
Please sign in to leave a comment.
You can set working directory for your notebook in Settings(Preferences on OS X)| Languages&Frameworks| Jupyter Notebook| Working Directory. Please let me know if you have any problems with it.
Yes! That works!
However, it seems to be setting not for a notebook but for all notebooks in project.
Yes, it's true because it's expected that all your notebooks have one working directory in the current project. If you miss an option to have different working directories please feel free to file an issue to Pycharm issue tracker: https://youtrack.jetbrains.com/issues/PY.
Hello, is this only an answer for the PyCharm Professional version? I have the Community version and I do not seem to find the option to set the WD under Languages&Frameworks > Jupyter Notebook.
No longer valid as of Pycharm Professional 2018.3. There is no setting for working directory in that dialog.
Yes - Oct 9 2019 also does not have this setting 2019.2 Pro
Same problem here, I can't find where the working dir can be set.
Support was removed here: https://youtrack.jetbrains.com/issue/PY-32934
Adding it back is being considered here: https://youtrack.jetbrains.com/issue/PY-35329 . Upvote if you're interested!