Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Although the question doesn't explicitly say so, I'm going to guess that the OP is running OSX (as assumed in other answers).

The fundamental problem here is that OSX applications don't read .bashrc or .profile like the shell does. There are several ways to modify the PATH variable for Mac Applications, as described on this stack exchange question. I used the wrapper-script answer by Rene to set my environment for Sage. It has the advantage of providing the same environment to Sage.app that you would expect at the command line, and it works across all notebooks (unlike above answers that modify PATH from within the notebook).

  1. Create a file at /Applications/Sage-version.app/Contents/MacOS/Sage.sh with the following text:

    #!/bin/bash
    if [[ -x $HOME/.profile ]]; then
      source $HOME/.profile
    fi
    exec "`dirname \"$0\"`/Sage" "$@"
    
  2. Make the file executable

    chmod +x /Applications/Sage-*.app/Contents/MacOS/Sage.sh
    
  3. Edit /Applications/Sage-version.app/Contents/Info.plist. Change the CFBundleExecutable to point to the wrapper script

    <key>CFBundleExecutable</key>
    <string>Sage.sh</string>
    
  4. Notify LaunchServices that the Info.plist has changed, either by restarting or by running

    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/Sage-*.app
    

This solution will also address errors running other cell interpreters, such as the LaTeX 'PDFLaTeX does not seem to be installed' error.