I am currently working on a machine learning project, and I would like to save my IPython files with the rest of my scripts. However, I have been unable to find any information on how to change the path that IPython files are saved to. "ipython locate" only gives me the location they are saved to, and does not appear to give me a way to change it, and the iPython editor does not have a file selector that I can use to change the save path. I am using Windows 10. Any help would be appreciated.
-
are you taking about IPython notebook? – Prashant Puri Jan 22 '16 at 04:49
-
are you looking for %save? Usage here https://ipython.org/ipython-doc/3/interactive/magics.html#magic-save give pathname to file, or save the entire session? http://stackoverflow.com/questions/947810/how-to-save-a-python-interactive-session not sure so don't want to post as answer – JimLohse Jan 22 '16 at 04:49
-
Sorry - I'm new to IPython. I am referring to the notebook, yes, and I want to save all of the code written in the notebook into a ipynb file, and I want to choose the path of that file. – Alex Jan 22 '16 at 05:01
-
You check this StackOverflow [link1](http://stackoverflow.com/questions/15680463/change-ipython-working-directory) and [link2](http://stackoverflow.com/questions/18901185/ipython-notebook-save-location) – Prashant Puri Jan 22 '16 at 05:10
-
Are you really using ipython or Jupyter notebook with an ipython kernel? – AChampion Jan 22 '16 at 05:11
4 Answers
I believe this is covered in:
IPython Notebook save location
Basically, you need to change your profile. Assuming you haven't, do so via
ipython profile create
Then, you change the default directory, directly under:
# The directory to use for notebooks.
Note - I've only done this on mac and linux, but it seems to have worked for windows users in the above link.
-
I see - so I take that every time I want to save the iPython notebook in a different directory, I have to change the default directory? – Alex Jan 22 '16 at 05:14
-
I don't know of any way to change the save directory dynamically during the session. There is a "hack" posted as one of the answers here: http://stackoverflow.com/questions/18901185/ipython-notebook-save-location Here, you apparently use the fact that python will save to the current directory. Worth a try, but I don't have a windows machine to test on at the moment ... – Orko Jan 22 '16 at 05:26
By default ipython
and jupyter
set the top of the working tree to the current directory at the time of launching the notebook server. You can change this by setting c.NotebookApp.notebook_dir
in the either the .ipython/profile_XXX/ipython_notebook_config.py
or .jupyter/jupyter_notebook_config.py
(*nix/Mac - not sure where these are located on Windows).
As long as the top of working tree includes the subdirectory with your scripts then you can just use the cmd/explorer to move the .ipynb
to your scripts directory and then browse http://localhost:XXXX/tree
to open the ipython notebook.

- 29,683
- 4
- 59
- 75
From your question, I think You need something similar to This Answer. If you are looking for changing working directory, this will help.
https://stackoverflow.com/a/20024051/987770
Thanks
If you are starting a new notebook you can specify its location directly on the command line:
ipynb /path/to/desired/folder
this will create the new notebook in the desired folder.

- 9,269
- 10
- 65
- 86