Ask Your Question

How to add path on sage startup

asked 2012-04-11 00:00:17 -0600

twch gravatar image


Is there a possibility to add a user defined path to the standard sage paths? I can add the path by typing

sage: import sys

sage: sys.path.append('mypath')

and everything works fine. But I don't like to do it all the times by hand but rather have the path added as standard.

I thougth about writing a bash wrapper skript but

export PATH=$PATH:mypath

seems to have no effect and be overwritten after sage startup.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-04-11 03:09:54 -0600

niles gravatar image

updated 2012-04-11 03:33:01 -0600

If you are adding this directory to your path so that you can load files from it, you can use the environment variable LOAD_ATTACH_PATH. It is described in the section about the preparser in the reference manual.

If you want to modify the path for some other reason, or execute other shell commands on startup, you could use the answer posted to this question:

edit flag offensive delete link more


The second proposal worked fine. I just created a file init.sage in $HOME/.sage with the following content import sys sys.path.append('/usr/local/root/lib') The other proposal seems not to work for me since I want to import a module from the attached path and not load or attach a file.

twch gravatar imagetwch ( 2012-04-11 04:09:30 -0600 )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: 2012-04-11 00:00:17 -0600

Seen: 1,231 times

Last updated: Apr 11 '12