[python] IPython Notebook save location

I just started IPython Notebook, and I tried to use "Save" to save my progress. However, instead of saving the *.ipynb in my current working directory, it is saved in my python/Scripts folder. Would there be a way to set this?

Thanks!

This question is related to python ipython ipython-notebook

The answer is


Yes, you can specify the notebooks location in your profile configuration. Since it's not saving them to the directory where you started the notebook, I assume that you have this option set in your profile. You can find out the the path to the profiles directory by using:

$ ipython locate

Either in your default profile or in the profile you use, edit the ipython_notebook_config.py file and change the lines:

Note: In case you don't have a profile, or the profile folder does not contain the ipython_notebook_config.py file, use ipython profile create.

# The directory to use for notebooks.
c.NotebookManager.notebook_dir = u'/path/to/your/notebooks'

and

# The directory to use for notebooks.
c.FileNotebookManager.notebook_dir = u'/path/to/your/notebooks'

Or just comment them out if you want the notebooks saved in the current directory.

Update (April 11th 2014): in IPython 2.0 the property name in the config file changed, so it's now:

c.NotebookApp.notebook_dir = u'/path/to/your/notebooks'

  1. Based on my experience, if you use "ipython.exe" in python-2.7.5/Scripts from other directory, as typing at the comamnd prompt as ipython notebook, *.ipynb files will be loaded and saved in the current directory. ("notebook" is just a comamnd line parameter) I think the "ipython notebook.exe" in Winpython top directory is not relevant for your request. As for me, I added the ipython.exe directory to the Path only.
  2. If you want to make your profile in user directory, see below: https://code.google.com/p/winpython/wiki/Installation#Settings

Just cd to your working folder and then start the IPython notebook server. This way you can be mobile.


If you're using IPython 4.x/Jupyter, run

$ jupyter notebook --generate-config

This will create a file jupyter_notebook_config.py in ~/.jupyter. This file already has a line starting with # c.NotebookApp.notebook_dir=u''.

All you need to do is to uncomment this line and change the value to your desired location, e.g., c.NotebookApp.notebook_dir=u'/home/alice/my_ipython_notebooks'


I tried the other solutions, but I didn't find that c.NotebookApp.notebook_dir setting in the config...

#jupyter_notebook_config.json

{
  "NotebookApp": {
    "nbserver_extensions": {
      "jupyter_nbextensions_configurator": true
    }
  }
}

So, what I do is:

  • cd into the directory where I want the notebooks and checkpoints saved
  • start the notebook server jupyter-lab
  • then, in an active notebook cell, I change my working directory so that the code in my python cells can access my other modules =)
# ipython cell
import os

# change where notebooks are stored
os.chdir('/Users/me/Project')
os.getcwd()

To run in Windows, copy this *.bat file to each directory you wish to use and run the ipython notebook by executing the batch file. This assumes you have ipython installed in windows.

set "var=%cd%"
cd var
ipython notebook

To add to Victor's answer, I was able to change the save directory on Windows using...

c.NotebookApp.notebook_dir = 'C:\\Users\\User\\Folder'

Jupyter under the WinPython environment has a batch file in the scripts folder called:

make_working_directory_be_not_winpython.bat

You need to edit the following line in it:

echo WINPYWORKDIR = %%HOMEDRIVE%%%%HOMEPATH%%\Documents\WinPython%%WINPYVER%%\Notebooks>>"%winpython_ini%"

replacing the Documents\WinPython%%WINPYVER%%\Notebooks part with your folder address.

Notice that the %%HOMEDRIVE%%%%HOMEPATH%%\ part will identify the root and user folders (i.e. C:\Users\your_name\) which will allow you to point different WinPython installations on separate computers to the same cloud storage folder (e.g. OneDrive) where you could store, access, and work with the same files from different machines. I find that very useful.


Examples related to python

programming a servo thru a barometer Is there a way to view two blocks of code from the same file simultaneously in Sublime Text? python variable NameError Why my regexp for hyphenated words doesn't work? Comparing a variable with a string python not working when redirecting from bash script is it possible to add colors to python output? Get Public URL for File - Google Cloud Storage - App Engine (Python) Real time face detection OpenCV, Python xlrd.biffh.XLRDError: Excel xlsx file; not supported Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation

Examples related to ipython

How to increase image size of pandas.DataFrame.plot in jupyter notebook? Importing .py files in Google Colab Selection with .loc in python IOPub data rate exceeded in Jupyter notebook (when viewing image) Purpose of "%matplotlib inline" Installing a pip package from within a Jupyter Notebook not working convert json ipython notebook(.ipynb) to .py file In which conda environment is Jupyter executing? How to make inline plots in Jupyter Notebook larger? %matplotlib line magic causes SyntaxError in Python script

Examples related to ipython-notebook

collapse cell in jupyter notebook Simple way to measure cell execution time in ipython notebook Using both Python 2.x and Python 3.x in IPython Notebook How do I add python3 kernel to jupyter (IPython) How to hide code from cells in ipython notebook visualized with nbviewer? Show DataFrame as table in iPython Notebook How to show PIL Image in ipython notebook ipython notebook clear cell output in code Format certain floating dataframe columns into percentage in pandas Pandas - Plotting a stacked Bar Chart