Ask Your Question
2

How to add path on sage startup

asked 13 years ago

twch gravatar image

Hi,

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 13 years ago

niles gravatar image

updated 12 years ago

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:

http://ask.sagemath.org/question/1072...

Preview: (hide)
link

Comments

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

The first reference link should now point here http://doc.sagemath.org/html/en/refer...

j.c. gravatar imagej.c. ( 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

Stats

Asked: 13 years ago

Seen: 3,215 times

Last updated: Apr 11 '12