0

So I installed Sage by downloading the .dmg and dragging the sage folder onto my desktop. I am confused.

  1. How did sage install Python 2.7 during this process? Or must I have already had it installed?

  2. Where is sage actually installed in my system?

I ask these questions because I am having trouble using/importing sage into my Python scripts and I think it may have something to do with the way it was installed. Must I compile it from source to use it in Python?

  • sage has nothing to do with python. what happens when you run `sage` from bash? – Padraic Cunningham Jul 09 '14 at 17:09
  • -bash: sage: command not found –  Jul 09 '14 at 17:16
  • @Padraic I have to be in the sage folder to run sage from bash –  Jul 09 '14 at 17:16
  • you don't have the path set then, if you run `/usr/bin/sage` does it start? – Padraic Cunningham Jul 09 '14 at 17:22
  • `-bash: /usr/bin/sage: No such file or directory` @PadraicCunningham that is the error I get –  Jul 09 '14 at 17:31
  • `/usr/local/bin/sage`? – Padraic Cunningham Jul 09 '14 at 17:36
  • `-bash: /usr/local/bin/sage: No such file or directory` is the error now. @PadraicCunningham This is why I think that there's something wrong with my sage install. It doesn't make sense to me that dragging and dropping a folder from a .dmg image onto my desktop would install sage. I can run sage if I'm inside the sage directory but not outside of it. –  Jul 09 '14 at 18:25
  • how to install system wide is here http://www.sagemath.org/doc/installation/source.html – Padraic Cunningham Jul 09 '14 at 18:50
  • @PadraicCunningham AHA, so the answer is yes, I need to install from source. What advantages does this give me? Will I be able to import sage into my python scripts then? –  Jul 09 '14 at 18:53
  • you can probably link to the binary in the dmg , I don't use mac but there are instructions in the link of various ways to do it. – Padraic Cunningham Jul 09 '14 at 19:13
  • You do know you cannot import sage into your system python? – Padraic Cunningham Jul 09 '14 at 19:21
  • All I've been trying to do for the past few days is do sage computations inside of a python script for an online website, so someone could type in sage code and have the answer displayed. I know it's possible because people do it all the time. But when I do from sage.all import * I get an error: "no module named sage.all" –  Jul 09 '14 at 19:35
  • it does not work like that, look here http://www.sagemath.org/doc/faq/faq-usage.html#how-do-i-import-sage-into-a-python-script – Padraic Cunningham Jul 09 '14 at 19:41
  • @PadraicCunningham then how do people set up sage servers? –  Jul 09 '14 at 20:58

1 Answers1

0

Sage absolutely has put a copy of a functioning Python on your computer during this install! (I assume you are on a Mac.)

You can always run any (executable with your permissions) thing from elsewhere. Let's assume you have dragged a folder named sage-6.2 onto your Desktop. (I don't know that to be the case, but let's say it is so. Then in a standard shell, if you are just in your home directory, this should work.

$ pwd # your home directory, hopefully
/Users/myusername
$ Desktop/sage-6.2/sage
<Sage starts up>

Or:

$ cd Desktop/sage-6.2 # change directory to the Sage one
$ ./sage 
<starts up>

And from any old directory,

$ cd random/directory/long/list
$ ~/Desktop/sage-6.2/sage
<starts up>

But Sage does not install in the "usual" way of putting executables in /usr/bin/ or any of those places, unless you put it there. That is actually a feature, since it keeps things clean and more accessible to those without Unix experience.

kcrisman
  • 4,374
  • 20
  • 41
  • And of course you can always add the folder Sage is in to your PATH. – kcrisman Jul 09 '14 at 18:42
  • @kcrisman two more questions, one, how can I add the folder sage is in to my PATH, and two, how did sage install python 2.7 on my computer when all I did was drag and drop a folder to my desktop? I don't understand it, was it going on in the background? Wouldn't my computer warn me that by dragging and dropping this random folder it was also installing Python in my system library? –  Jul 09 '14 at 18:52
  • It didn't install it in the "system library", whatever that is. There is just now a functioning Python in your Sage folder. I'm not sure why that would need a warning. It is *not* the same Python as the one preinstalled in Mac, or as whatever one would be installed on Linux if one chose. It's just a program, like any other program. I tried to clarify in my answer. – kcrisman Jul 09 '14 at 20:38
  • http://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path – kcrisman Jul 09 '14 at 20:39