Ask Your Question

Sage Python CGI - Error: environment variable $HOME is not set.

asked 2013-03-08 12:05:15 -0500

Nathan K gravatar image


I am trying to access sage libraries from within a python script (CGI on Apache). I'm getting this error every time:

Error: environment variable $HOME is not set. Error setting environment variables by sourcing '/opt/sage-5.7/spkg/bin/sage-env'; possibly contact sage-devel (see

This is the line that produces the error: #!/opt/sage-5.7/sage --python

The error doesn't occur when I run the script from the command line. It may be an issue with the user that the script is being run under, but I am not sure how to resolve it. Any suggestions?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-03-09 03:54:37 -0500

Why don't you set $HOME in your python script? Maybe try

if 'HOME' not in os.environ:
    os.environ['HOME'] = ...something you have write access to...

(The script $SAGE_ROOT/spkg/bin/sage-env, which is run each time Sage starts up, requires that $HOME is set.)

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2013-03-08 12:05:15 -0500

Seen: 491 times

Last updated: Mar 09 '13