Ask Your Question

sagemath windows 8.1 launching jupyter from another directory or drive

asked 2018-03-02 01:17:09 +0200

c05772 gravatar image

updated 2019-01-09 17:55:37 +0200

FrédéricC gravatar image

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 flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2018-03-02 01:22:28 +0200

c05772 gravatar image

updated 2018-03-03 21:05:14 +0200

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/

    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\, 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.
edit flag offensive delete link more

answered 2018-03-02 01:52:40 +0200

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/

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
edit flag offensive delete link more


For a directory this is OK but for a drive?

c05772 gravatar imagec05772 ( 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.)

John Palmieri gravatar imageJohn Palmieri ( 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 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.

c05772 gravatar imagec05772 ( 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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-03-02 01:17:09 +0200

Seen: 1,111 times

Last updated: Mar 03 '18