ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 28 Dec 2013 22:39:09 +0100How to use Sage in terminal?https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/Dear All,
I am trying to use sage in Mac OSX. I already installed the binary distribution.
The problem is I cannot access the sage environment in terminal and when I
run sage in Mac it opens Sage Notebook. The thing is I am trying to install
PyMVPA and Nibabel in Sage, but as I look into guides I need to go through these
steps according to:
http://sites.google.com/site/neuroinformaticsimageanalysis/home/sage-in-medical-imaging
Install pynifti and pymvpa
-Download latest versions of pynifti and pymvpa
-In the unpacked directories of pynifti and pymvpa and within a Sage environment
(i.e. " $ sage -sh "), install the modules. I.e. " $ make all " and " $ python setup install ".
Check installation by " sage: import pynifti " and " sage: import mvpa "
and when I type "sage -sh" in terminal it opens the sage process and the notebook in Safari!
So I don't know where and when I need to type the rest which are "make all" and "python setup install"
I would be really grateful if someone helps.Sun, 01 Apr 2012 17:34:26 +0200https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/Answer by Naji for <p>Dear All,</p>
<p>I am trying to use sage in Mac OSX. I already installed the binary distribution.
The problem is I cannot access the sage environment in terminal and when I
run sage in Mac it opens Sage Notebook. The thing is I am trying to install
PyMVPA and Nibabel in Sage, but as I look into guides I need to go through these
steps according to:</p>
<p><a href="http://sites.google.com/site/neuroinformaticsimageanalysis/home/sage-in-medical-imaging">http://sites.google.com/site/neuroinf...</a></p>
<p>Install pynifti and pymvpa
-Download latest versions of pynifti and pymvpa
-In the unpacked directories of pynifti and pymvpa and within a Sage environment
(i.e. " $ sage -sh "), install the modules. I.e. " $ make all " and " $ python setup install ".
Check installation by " sage: import pynifti " and " sage: import mvpa " </p>
<p>and when I type "sage -sh" in terminal it opens the sage process and the notebook in Safari!
So I don't know where and when I need to type the rest which are "make all" and "python setup install"</p>
<p>I would be really grateful if someone helps.</p>
https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?answer=13416#post-id-13416Thanks a lot for your response. Well at least entering "sage -sh" in terminal should result in "sage prompt" which in my case opens the sage notebook!!
Let me first mention something I forgot to! I always have to run sage from terminal with root privileges to be able to run it correctly and if not running sage(same as clicking it in Applications) results in a new tab which states that server is starting but nothing happens! Another new tab with the address localhost:8888 only opens if I ran sage with root privileges! By the way I copied the application from the dmg to my Applications folder!
Now about the method you told, I've found the terminal submenu and ran it and I faced this:
/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/sage; exit
----------------------------------------------------------------------
| Sage Version 4.7.2, Release Date: 2011-10-29 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
[Errno 13] Permission denied: '/Users/******/.sage//temp/****s_MacBook_Air.local/2810/'
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/local/bin/<string> in <module>()
/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/misc/preparser_ipython.py in <module>()
6 ###########################################################################
7
----> 8 import sage.misc.interpreter
9
10 import preparser
/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/misc/interpreter.py in <module>()
100
101 import os
--> 102 import log
103 import re
104
/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/misc/log.py in <module>()
63
64 import interpreter
---> 65 import latex
66 import misc
67
/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/misc/latex.py in <module>()
63 import types
64
---> 65 from misc import tmp_dir, graphics_filename
66 import sage_eval
67 from sage.misc.sage_ostools import have_program
/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/misc/misc.py in <module>()
116 except OSError, msg:
117 print msg
--> 118 raise OSError, " ** Error trying to create the Sage tmp directory in your home directory. A possible cause of this might be that you built or upgraded Sage after typing 'su'. You probably need to delete the directory $HOME/.sage."
119
120 SAGE_DATA = '%s/data/'%SAGE_ROOT
OSError: ** Error trying to create the Sage tmp directory in your home directory. A possible cause of this might be that you built or upgraded Sage after typing 'su'. You probably need to delete the directory $HOME/.sage.
WARNING: Failure executing code: 'import sage.misc.preparser_ipython; sage.misc.preparser_ipython.magma_colon_equals=True'
[Errno 13] Permission denied: '/Users/******/.sage//temp/****s_MacBook_Air.local/2810/'
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/IPython/ipmaker.pyc in force_import(modname, force_reload)
61 reload(sys.modules[modname])
62 else:
---> 63 __import__(modname)
64
65
/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/local/bin/ipy_profile_sage.py in <module>()
1 import os
2 if 'SAGE_CLEAN' not in os.environ:
----> 3 import sage.misc.misc
4 from sage.misc.interpreter import preparser, _ip
5 preparser(True)
/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/misc/misc.py in <module>()
116 except OSError, msg:
117 print msg
--> 118 raise OSError, " ** Error trying to create the Sage tmp directory in your home directory. A possible cause of this might be that you built or upgraded Sage after typing 'su'. You probably need to delete the directory $HOME/.sage."
119
120 SAGE_DATA = '%s/data/'%SAGE_ROOT
OSError: ** Error trying to create the Sage tmp directory in your home directory. A possible cause of this might be that you built or upgraded Sage after typing 'su'. You probably need to delete the directory $HOME/.sage.
Error importing ipy_profile_sage - perhaps you should run %upgrade?
WARNING: Loading of ipy_profile_sage failed.
<ERROR: name 'sage_prompt' is not defined>
Any helps will be greatly welcomed :)Mon, 02 Apr 2012 16:41:21 +0200https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?answer=13416#post-id-13416Answer by rpietro for <p>Dear All,</p>
<p>I am trying to use sage in Mac OSX. I already installed the binary distribution.
The problem is I cannot access the sage environment in terminal and when I
run sage in Mac it opens Sage Notebook. The thing is I am trying to install
PyMVPA and Nibabel in Sage, but as I look into guides I need to go through these
steps according to:</p>
<p><a href="http://sites.google.com/site/neuroinformaticsimageanalysis/home/sage-in-medical-imaging">http://sites.google.com/site/neuroinf...</a></p>
<p>Install pynifti and pymvpa
-Download latest versions of pynifti and pymvpa
-In the unpacked directories of pynifti and pymvpa and within a Sage environment
(i.e. " $ sage -sh "), install the modules. I.e. " $ make all " and " $ python setup install ".
Check installation by " sage: import pynifti " and " sage: import mvpa " </p>
<p>and when I type "sage -sh" in terminal it opens the sage process and the notebook in Safari!
So I don't know where and when I need to type the rest which are "make all" and "python setup install"</p>
<p>I would be really grateful if someone helps.</p>
https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?answer=15870#post-id-15870I had a similar problem and so just point to an alternate cause and solution: In my scenario I had zsh installed and it just didn't seem to recognize. simple solution was to move back to bash and I got my terminal session up and runningSat, 28 Dec 2013 22:39:09 +0100https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?answer=15870#post-id-15870Answer by Naji for <p>Dear All,</p>
<p>I am trying to use sage in Mac OSX. I already installed the binary distribution.
The problem is I cannot access the sage environment in terminal and when I
run sage in Mac it opens Sage Notebook. The thing is I am trying to install
PyMVPA and Nibabel in Sage, but as I look into guides I need to go through these
steps according to:</p>
<p><a href="http://sites.google.com/site/neuroinformaticsimageanalysis/home/sage-in-medical-imaging">http://sites.google.com/site/neuroinf...</a></p>
<p>Install pynifti and pymvpa
-Download latest versions of pynifti and pymvpa
-In the unpacked directories of pynifti and pymvpa and within a Sage environment
(i.e. " $ sage -sh "), install the modules. I.e. " $ make all " and " $ python setup install ".
Check installation by " sage: import pynifti " and " sage: import mvpa " </p>
<p>and when I type "sage -sh" in terminal it opens the sage process and the notebook in Safari!
So I don't know where and when I need to type the rest which are "make all" and "python setup install"</p>
<p>I would be really grateful if someone helps.</p>
https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?answer=13408#post-id-13408I have found the problem. I linked to a wrong sage in terminal. To run "sage -sh" in terminal you need to run "sage -sh" in "/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/" and link sage to this file in the folder!
Wed, 04 Apr 2012 10:24:03 +0200https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?answer=13408#post-id-13408Comment by kcrisman for <p>I have found the problem. I linked to a wrong sage in terminal. To run "sage -sh" in terminal you need to run "sage -sh" in "/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/" and link sage to this file in the folder!</p>
https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?comment=19990#post-id-19990Great, you solved that problem yourself! Good sleuthing - and yes, you definitely have to use *this* `sage`.Wed, 04 Apr 2012 14:25:43 +0200https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?comment=19990#post-id-19990Answer by niles for <p>Dear All,</p>
<p>I am trying to use sage in Mac OSX. I already installed the binary distribution.
The problem is I cannot access the sage environment in terminal and when I
run sage in Mac it opens Sage Notebook. The thing is I am trying to install
PyMVPA and Nibabel in Sage, but as I look into guides I need to go through these
steps according to:</p>
<p><a href="http://sites.google.com/site/neuroinformaticsimageanalysis/home/sage-in-medical-imaging">http://sites.google.com/site/neuroinf...</a></p>
<p>Install pynifti and pymvpa
-Download latest versions of pynifti and pymvpa
-In the unpacked directories of pynifti and pymvpa and within a Sage environment
(i.e. " $ sage -sh "), install the modules. I.e. " $ make all " and " $ python setup install ".
Check installation by " sage: import pynifti " and " sage: import mvpa " </p>
<p>and when I type "sage -sh" in terminal it opens the sage process and the notebook in Safari!
So I don't know where and when I need to type the rest which are "make all" and "python setup install"</p>
<p>I would be really grateful if someone helps.</p>
https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?answer=13413#post-id-13413You must have installed the Sage application bundle (Sage.app), to give you a double-clickable application which shows up in your Dock -- is that right? If so, you can open a shell session from that application. Activate the application and look for the "Terminal Session" menu (next to "File", "Edit", "Server"). In that menu, choose "Misc. > sh" and this will open the sage shell.Mon, 02 Apr 2012 10:42:39 +0200https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?answer=13413#post-id-13413Comment by kcrisman for <p>You must have installed the Sage application bundle (Sage.app), to give you a double-clickable application which shows up in your Dock -- is that right? If so, you can open a shell session from that application. Activate the application and look for the "Terminal Session" menu (next to "File", "Edit", "Server"). In that menu, choose "Misc. > sh" and this will open the sage shell.</p>
https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?comment=20003#post-id-20003Can you also give him command line arguments from Terminal?Mon, 02 Apr 2012 12:09:45 +0200https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?comment=20003#post-id-20003Comment by Naji for <p>You must have installed the Sage application bundle (Sage.app), to give you a double-clickable application which shows up in your Dock -- is that right? If so, you can open a shell session from that application. Activate the application and look for the "Terminal Session" menu (next to "File", "Edit", "Server"). In that menu, choose "Misc. > sh" and this will open the sage shell.</p>
https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?comment=19992#post-id-19992@kcrisman you can find it in my last post in this thread!Wed, 04 Apr 2012 10:25:43 +0200https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?comment=19992#post-id-19992Answer by niles for <p>Dear All,</p>
<p>I am trying to use sage in Mac OSX. I already installed the binary distribution.
The problem is I cannot access the sage environment in terminal and when I
run sage in Mac it opens Sage Notebook. The thing is I am trying to install
PyMVPA and Nibabel in Sage, but as I look into guides I need to go through these
steps according to:</p>
<p><a href="http://sites.google.com/site/neuroinformaticsimageanalysis/home/sage-in-medical-imaging">http://sites.google.com/site/neuroinf...</a></p>
<p>Install pynifti and pymvpa
-Download latest versions of pynifti and pymvpa
-In the unpacked directories of pynifti and pymvpa and within a Sage environment
(i.e. " $ sage -sh "), install the modules. I.e. " $ make all " and " $ python setup install ".
Check installation by " sage: import pynifti " and " sage: import mvpa " </p>
<p>and when I type "sage -sh" in terminal it opens the sage process and the notebook in Safari!
So I don't know where and when I need to type the rest which are "make all" and "python setup install"</p>
<p>I would be really grateful if someone helps.</p>
https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?answer=13421#post-id-13421I'm afraid I don't know what to do about this, but here are the parts of the output that look especially important:
1: The top line is
/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/sage
This is the command you can type in the Terminal to start the command-line sage instead of the notebook.
2: The OS Error may be a partial explanation of why you have to start Sage with root access:
OSError: ** Error trying to create the Sage tmp directory in your home directory.
A possible cause of this might be that you built or upgraded Sage
after typing 'su'. You probably need to delete the directory $HOME/.sage.
If you won't lose anything valuable, you should follow these instructions and delete the `.sage` directory. WARNING: This is the directory that stores **all** of your sage-related data. Deleting it will delete all of your saved notebooks. Before you do this, you should export anything you don't want to lose to a `.sws` file. When you're ready, you can delete the directory with
sudo rm -rf ~/.sage
Once you've done that, try to start Sage, but *not* as the root user: To ensure that you are no longer functioning as root user, you could quit the Terminal and then reopen it. When you have done this, type the command to start Sage and it will automatically create a new `.sage` directory for you -- this time with (hopefully) the correct permissions.
Good luck!
Wed, 04 Apr 2012 09:02:43 +0200https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?answer=13421#post-id-13421Comment by Naji for <p>I'm afraid I don't know what to do about this, but here are the parts of the output that look especially important:</p>
<p>1: The top line is</p>
<pre><code>/Applications/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/sage
</code></pre>
<p>This is the command you can type in the Terminal to start the command-line sage instead of the notebook.</p>
<p>2: The OS Error may be a partial explanation of why you have to start Sage with root access:</p>
<pre><code>OSError: ** Error trying to create the Sage tmp directory in your home directory.
A possible cause of this might be that you built or upgraded Sage
after typing 'su'. You probably need to delete the directory $HOME/.sage.
</code></pre>
<p>If you won't lose anything valuable, you should follow these instructions and delete the <code>.sage</code> directory. WARNING: This is the directory that stores <strong>all</strong> of your sage-related data. Deleting it will delete all of your saved notebooks. Before you do this, you should export anything you don't want to lose to a <code>.sws</code> file. When you're ready, you can delete the directory with</p>
<pre><code>sudo rm -rf ~/.sage
</code></pre>
<p>Once you've done that, try to start Sage, but <em>not</em> as the root user: To ensure that you are no longer functioning as root user, you could quit the Terminal and then reopen it. When you have done this, type the command to start Sage and it will automatically create a new <code>.sage</code> directory for you -- this time with (hopefully) the correct permissions.</p>
<p>Good luck!</p>
https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?comment=19993#post-id-19993Thank you very much for this post. Now I am able to run the Sage without root privileges. But when I use "sage -sh" it again opens the sage notebook! And I have to access the sage terminal from the menu. Also none of the "$ make all" and "$ python setup install" are working in this terminal! What do I need to do in order to add a module like pyNifti or Nibabel to Sage then?Wed, 04 Apr 2012 09:50:50 +0200https://ask.sagemath.org/question/8842/how-to-use-sage-in-terminal/?comment=19993#post-id-19993