Make sure to run sage -sh from a shell first! That sets all the right environment variables. (See comments for further details about this person's use case.)