Ask Your Question

Running Sagemath 8.2 natively in Windows, how to change the Jupyter default directory?

asked 2018-05-27 04:59:30 +0200

res0001 gravatar image

updated 2018-05-28 01:08:20 +0200

With SageMath 8.2 running natively under Windows 10, the Jupyter dashboard opens by default in the directory C:\Users\<me>, so I then have to navigate to the desired directory that contains my Jupyter notebook .ipynb files.

How can I cause Jupyter to open directly in the desired directory?

The relevant Windows shortcut has the following Target Property:

"C:\Program Files\SageMath 8.2\runtime\bin\mintty.exe" -t 'SageMath 8.2 Notebook Server' -i sagemath.ico /bin/bash --login -c '/opt/sagemath-8.2/sage --notebook jupyter'

Can the sage --notebook jupyter portion be adjusted somehow to specify the desired directory?

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted

answered 2018-05-27 09:41:29 +0200

danielvolinski gravatar image

Locate file fstab in SageMath_Installation\runtime\etc and add a new line at the end, like this

"D:\Users\danie_000\Sage /home/danie_000 ntfs binary,posix=1,acl 0 0" (without the quotes)

Of course you should adapt the line to your user <me> not danie_000.

From now on the Jupyter folder will be opened at D:\Usersdanie_000\Sage

Details at

C:\Users\<Your Windows Username>\<Your preferred Sage home> /home/<Your Windows username> ntfs binary,posix=1,acl 0 0


edit flag offensive delete link more


Thank you! That seems to be working after I changed my directory names to remove all spaces from them.

res0001 gravatar imageres0001 ( 2018-05-27 17:46:07 +0200 )edit

Note: The next release of Sage for Windows will also have the option to select your default home directory (and also change it as desired).

Iguananaut gravatar imageIguananaut ( 2018-07-10 13:34:01 +0200 )edit

Hi Sagemath 8.3 for W10

for the purpose of working in my C: \ Users \ jean-pierre \ Documents \ SageMath \ IPYNB directory

I put this line below in the file C:\Program Files\SageMath 8.3\runtime\etc\fstab.d

REM (initial) 8.3 C:\Users\jean-pierre /home/sage ntfs binary,posix=1,usr,acl 0 0
REM (initial) Old 8.2 C:\Users /home ntfs binary,posix=1,acl 0 0
C:\Users\jean-pierre\Documents\SageMath\IPYNB  /home/jean-pierre ntfs binary,posix=1,acl 0 0

but unfortunately that does not work as in fstab for 8.2, moreover the file fstab has been renamed fstab.d in 8.3. and the command executed from within the Sage Shell : sage-sethome "C:\Users\jean-pierre\Documents\SageMath\IPYNB"

does not work too, despite I got the message : see next comment not enough place in this comment ;-(

ortollj gravatar imageortollj ( 2018-08-27 10:46:11 +0200 )edit

Note: SAGE_ROOT=/opt/sagemath-8.3 (sage-sh) jean-pierre@ToshibaJPO:~$ sage-sethome "C:\Users\jean-pierre\Documents \SageMath\IPYNB" Sage home directory set to 'C:\Users\jean-pierre\Documents\SageMath\IPYNB' Close and restart all Sage sessions for the new setting to take effect.

ortollj gravatar imageortollj ( 2018-08-27 11:18:51 +0200 )edit

Yes, on 8.3 use sage-sethome. Also /etc/fstab and /etc/fstab.d are not the same thing.

Iguananaut gravatar imageIguananaut ( 2018-08-29 14:01:24 +0200 )edit

answered 2018-08-29 14:03:51 +0200

Iguananaut gravatar image

Starting on SageMath 8.3 for Windows, the installer gives you the option (when you do a single-user install) to specify the directory that you wish to be your "home" directory for all things included in the Sage distribution.

After installation you can change this by running, in the shell,

$ sage-sethome <new-home-directory>

where <new-home-directory> can be a Windows path (use quotes if the path contains spaces).

After running sage-sethome it's necessary to close and restart any Sage interpreter or shell sessions for the home directory to change.

edit flag offensive delete link more


As of writing there is a small typo in sage-sethome that makes it buggy. After running sage-sethome, run also sed -i 's/posix=1,usr/posix=1/user/' /etc/fstab.d/* and it will work.

Iguananaut gravatar imageIguananaut ( 2018-08-29 14:12:47 +0200 )edit

I got this message executing: (sage-sh) jean-pierre@ToshibaJPO:~$ sed -i "s/posix=1,usr/posix=1/user/" /etc/fstab.d/*

sed: -e expression n°1, caractère 23: option inconnue pour `s' (sage-sh) jean-pierre@ToshibaJPO:~$

ortollj gravatar imageortollj ( 2018-08-30 08:48:26 +0200 )edit

this is the content of the file named jean-pierre (it's my user name for windows) in the directory C:\Program Files\SageMath 8.3\runtime\etc\fstab.d could you please tell me what I should change ?:

C:\Users\jean-pierre\Documents\SageMath\IPYNB /home/sage ntfs binary,usr/posix=1/user/,usr,acl 0 0

note that there is a blank here --> SageMath 8.3

ortollj gravatar imageortollj ( 2018-08-31 09:45:21 +0200 )edit

where it says "usr" that should be spelled "user". This is a bug. Also sorry, there was a typo in the sed command I gave you. It should be sed -i 's/posix=1,usr/posix=1,user/' /etc/fstab.d/* (I wrote / instead of ,)

Iguananaut gravatar imageIguananaut ( 2018-09-04 12:30:58 +0200 )edit

Anyways, I'll be uploading a new install with the fixed sage-sethome soon.

Iguananaut gravatar imageIguananaut ( 2018-09-04 12:31:43 +0200 )edit

answered 2018-05-27 09:52:37 +0200

eric_g gravatar image

updated 2018-05-27 09:56:17 +0200

Another possibility could be to add the option --notebook-dir to the command sage --notebook jupyter:

sage --notebook jupyter --notebook-dir directory_name
edit flag offensive delete link more


This is along the lines I'd hoped for, but unfortunately it doesn't work. (I also tried it using an equals sign: --notebook-dir=directory_name.)

res0001 gravatar imageres0001 ( 2018-05-27 17:01:50 +0200 )edit

Too bad! (this works with Linux, but I could not tell for Windows)

eric_g gravatar imageeric_g ( 2018-05-27 21:06:45 +0200 )edit

I don't understand. It works for me. But you have to make sure to pass a posix-style path.

Iguananaut gravatar imageIguananaut ( 2018-08-29 13:59:40 +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



Asked: 2018-05-27 04:59:30 +0200

Seen: 5,782 times

Last updated: Aug 29 '18