Ask Your Question
1

How to use Sage in terminal?

asked 2012-04-01 17:34:26 +0100

Naji gravatar image

updated 2015-01-13 22:25:14 +0100

FrédéricC gravatar image

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/neuroinf...

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.

edit retag flag offensive close merge delete

5 Answers

Sort by » oldest newest most voted
1

answered 2012-04-04 09:02:43 +0100

niles gravatar image

I'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!

edit flag offensive delete link more

Comments

Thank 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?

Naji gravatar imageNaji ( 2012-04-04 09:50:50 +0100 )edit
2

answered 2012-04-02 10:42:39 +0100

niles gravatar image

updated 2012-04-02 10:43:02 +0100

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.

edit flag offensive delete link more

Comments

Can you also give him command line arguments from Terminal?

kcrisman gravatar imagekcrisman ( 2012-04-02 12:09:45 +0100 )edit

@kcrisman you can find it in my last post in this thread!

Naji gravatar imageNaji ( 2012-04-04 10:25:43 +0100 )edit
1

answered 2012-04-04 10:24:03 +0100

Naji gravatar image

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!

edit flag offensive delete link more

Comments

Great, you solved that problem yourself! Good sleuthing - and yes, you definitely have to use *this* `sage`.

kcrisman gravatar imagekcrisman ( 2012-04-04 14:25:43 +0100 )edit
0

answered 2013-12-28 22:39:09 +0100

I 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 running

edit flag offensive delete link more
0

answered 2012-04-02 16:41:21 +0100

Naji gravatar image

updated 2012-04-02 16:42:22 +0100

Thanks 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 ...
(more)
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

Stats

Asked: 2012-04-01 17:34:26 +0100

Seen: 12,369 times

Last updated: Dec 28 '13