# sagemath windows 8.1 launching jupyter from another directory or drive

After installing sagemath 8.1 for windows, I try to launch jupyter from drive E:\ where the data are, instead of C:\ which is a SSD. It is not possible once in the browser to switch to another disk as reported in various places on internet.

What is the best work around?

edit retag close merge delete

Sort by » oldest newest most voted

I have the following work around. I launch the SageMath shell from the Windows shortcut.

Then to start from E:\username, I type

(sage-sh)> cd /cygdrive/e/username and then (sage-sh)> jupyter notebook

It is quick but not as fast as the "SageMath 8.1 Notebook" shortcut directly installed by the software.

Experimenting again, I found this "hybrid Linux Windows" solution for the drive problem. I give the full solution for Windows below grouping John Palmieri answer (above) and mine for the user "UserName" willing to have the root directory of jupyter on drive E:, directory E:\UserName\Maths:

1. After installing SageMath 8.1 click on the shortcut "SageMath 8.1 Shell"

2. In this shell, execute the instruction :

sage -n jupyter --generate-config

3. It will generate the message:

Writing default config to: /dot_sage/jupyter-4.1/jupyter_notebook_config.py


Note that in a windows installation (with OS on the C: drive), this directory is in fact

4. Edit the file C:\Users\UserName.sagemath-8.1\jupyter-4.1\jupyter_notebook_config.py, replacing the line

#c.NotebookApp.notebook_dir = u''

(This line is numbered 195 in my editor, it is a standard default file, it should be the same in yours) with

     c.NotebookApp.notebook_dir = '/cygdrive\e\UserName\Maths'


Note the slashes orientation, you start in Linux mode and finsh in Windows !! This is NOT a typo.

1. Save the file and click the shortcut "SageMath 8.1 Notebook". Jupyter should have E:\UserName\Maths as root directory.
more

One option, if you want to define a directory to be the default Jupyter notebook directory: first run

sage -n jupyter --generate-config


This should print a message like

Writing default config to: /..../.sage/jupyter-4.1/jupyter_notebook_config.py


Now edit the named file: look for the lines

## The directory to use for notebooks and kernels.
#c.NotebookApp.notebook_dir = u''


and change the second: delete the # in front (which is a comment character) and replace the blank string '' with the directory you want.

If you have not done the preceding, then another option should be

sage -n jupyter --NotebookApp.notebook_dir=/path/to/dir

more

For a directory this is OK but for a drive?

( 2018-03-02 02:06:36 +0200 )edit

I don't know, since I don't use Sage with Windows. Give it a try and see what happens. (The second option is temporary, so try that first. If it works, then the first should work, too.)

( 2018-03-02 05:12:08 +0200 )edit

After trying multiple solutions, it seems that, in Windows, this solution works ONLY for directories below the C:\Users\UserName directory. It means if you want to start in the Documents directory of "UserName" you have to modify line 195 of the jupyter_notebook_config.py file with

c.NotebookApp.notebook_dir = u'\Documents'


the u is not necessary, you get the same result with

c.NotebookApp.notebook_dir = '\Documents'


and the fact that you can only use relative notation for the Documents directory confirms it.

Note also that you have to use the Windows backslash not the linux slash for the directory name.

( 2018-03-03 19:20:54 +0200 )edit

I wrote a global solution below combining your solution with mine for the drive problem. I hope it is OK like that. Thanks

( 2018-03-03 21:09:24 +0200 )edit