19

I've jus installed anaconda and I see that it wants me to save my documents in my documents/python scripts

But I'd rather save everything in my dropbox for easy backups. But I also want to be able to just call scripts by their name and not the whole path. Can this be set?

Coolcrab
  • 2,655
  • 9
  • 39
  • 59

8 Answers8

30

Not sure if this is helpful, but as of 11/2/15, Anaconda 2.4.0 moved to Jupyter, which has a different method for changing the default directory

In the command line type:

jupyter notebook --generate-config

Which will create a file named jupyter_notebook_config.py in your jupyter directory (In Windows Users/USERNAME/.jupyter). To change the default directory on startup, locate the line:

c.NotebookApp.notebook_dir = u''

And put your preferred directory in the quotes.

Ben
  • 2,308
  • 2
  • 18
  • 25
  • Ben, thanks for this set of commands. I'm on a mac (OS X 10.10.5) and followed these instructions. I was able to create the config file and change the startup directory, but when I start up my Jupyter notebook, it still takes me to the default directory (in my home user folder), instead of where I directed it with the command above. I've shut down Anacondas and restarted to no avail. Any ideas on how to get this change to take? – staypuffinpc Jul 08 '16 at 05:02
  • I'm not sure, seems like this should work for Mac as well. [This](http://stackoverflow.com/questions/15680463/change-ipython-working-directory/22824886#22824886) answer seems to provide a workaround, but it seems like it's the same thing as was marked as the answer to this question. – Ben Jul 08 '16 at 17:15
23

By default the directory where Jupyter was started is uses as a notebook directory. There are different situations where the IPython notebook directory change is necessary.

  1. To change the default notebook directory for all IPython kernel sessions:

    1.1. Open a command window and execute:

         jupyter notebook --generate-config
    

    This will generate .jupiter/jupyter_notebook_config.py file under your home directory.

    1.2. Find, un-comment and modify the following line in your jupyter_notebook_config.py to point to the desired directory:

    # c.NotebookApp.notebook_dir = ''
    

    Next time you launch IPython, it will open with the notebook directory you specified. For example, you can make D:\Sandbox to be your notebook directory:

     c.NotebookApp.notebook_dir = 'D://Sandbox'
    
  2. You can specify notebook directory per kernel session.

    In my everyday work I use Anaconda and IPython notebooks from different locations, including USB sticks. This makes changing the default directory impractical. I start IPython notebook from the command line, specifying the notebook directory.

        jupyter notebook --notebook-dir="D:\Sandbox"
    

    For frequently used directories, I create a command file in the directory itself. The command launches IPython with current directory as notebook directory. Here is what it looks like in a Windows command file:

       jupyter notebook --notebook-dir="%CD%"
    
Ivan Georgiev
  • 1,115
  • 7
  • 11
11

You can right click the Start menu shortcut and change the starting directory.

It's not as easy to change the directory used by the Launcher. I think in principle you could edit some file somewhere to change what directory it uses.

asmeurer
  • 86,894
  • 26
  • 169
  • 240
6

I have found a solution for this.

Get the python script that launches Jupyther Network app called jupyter-notebook-script.py (it is usually located in C:\Anaconda3\Scripts\). Then modify content of the script with this:

import sys
import notebook.notebookapp 

notebook.notebookapp.NotebookApp.notebook_dir = u'C:\\path\\to\\folder'

sys.exit(notebook.notebookapp.main())

It worked for me on Windows 7.

3

You can change the default directory for notebooks. It can be done permanently in ipython notebook config files. Firstly, locate the ipython profile, in the cmdline, type:

$> ipython locate

Default profile location (using Anaconda) is: %USERNAME%\.ipython

then, in file ipython_notebook_config.py (if it's default profile go into folder \profile_default), uncommnet and edit line:

c.FileNotebookManager.notebook_dir = u'C:\\Users\\Lukasz\\Documents\\Github'

changing the my path to whatever path you like.

Really useful website is: http://ipython.org/ipython-doc/dev/config/intro.html

After above step Ipython should start with proper path.

It works for me.

l.augustyniak
  • 1,794
  • 1
  • 15
  • 15
1

For Windows, edit the shortcut command which starts Jupyter:

from: ..\Anaconda3\Scripts\jupyter-notebook-script.py %USERPROFILE%

to : ..\Anaconda3\Scripts\jupyter-notebook-script.py c:\your_project_workspace

1

People visiting now in 2020 for Win10, The official instructions have been mentioned below. For me none of the methods like changing in conf.py etc helped.. We need to go to the shortcut properties and change the path there:

https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/execute.html#change-jupyter-notebook-startup-folder-windows

Yogesh Kumar Gupta
  • 1,009
  • 1
  • 10
  • 10
0

For change working directory on the Mac with Anaconda app Launcher Jupyter for another directory then home

change file /Applications/anaconda3/bin/jupyter_mac.command Your needed dir change path in example /Volumes/BOOTCAMP/

DIR=$(dirname $0)
$DIR/jupyter-notebook --notebook-dir=/Volumes/BOOTCAMP/