Ask Your Question

How to add path on sage startup

asked 2012-04-11 07:00:17 +0200

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 10:09:54 +0200

niles gravatar image

updated 2012-04-11 10:33:01 +0200

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 11:09:30 +0200 )edit

The first reference link should now point here

j.c. gravatar imagej.c. ( 2018-06-07 16:53:33 +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: 2012-04-11 07:00:17 +0200

Seen: 2,998 times

Last updated: Apr 11 '12