First time here? Check out the FAQ!

Ask Your Question
3

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

asked 6 years ago

res0001 gravatar image

updated 6 years ago

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?

Preview: (hide)

3 Answers

Sort by » oldest newest most voted
3

answered 6 years ago

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 https://github.com/sagemath/sage-wind...

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

Daniel

Preview: (hide)
link

Comments

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

res0001 gravatar imageres0001 ( 6 years ago )

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 ( 6 years ago )

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 ( 6 years ago )

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 ( 6 years ago )

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

Iguananaut gravatar imageIguananaut ( 6 years ago )
2

answered 6 years ago

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.

Preview: (hide)
link

Comments

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 ( 6 years ago )

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 ( 6 years ago )

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 ( 6 years ago )

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 ( 6 years ago )

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

Iguananaut gravatar imageIguananaut ( 6 years ago )
2

answered 6 years ago

eric_g gravatar image

updated 6 years ago

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

sage --notebook jupyter --notebook-dir directory_name
Preview: (hide)
link

Comments

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 ( 6 years ago )

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

eric_g gravatar imageeric_g ( 6 years ago )
1

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

Iguananaut gravatar imageIguananaut ( 6 years ago )

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 6 years ago

Seen: 6,571 times

Last updated: Aug 29 '18