Ask Your Question

app installation problem on mac os x lion

asked 2011-09-08 17:35:30 +0200

Louisa Grey gravatar image

updated 2015-10-22 21:37:07 +0200

FrédéricC gravatar image

I downloaded the 64-bit app version of Sage today, then dragged the app to my Applications folder. When I tried to open it, I got the following message in Terminal. I am new to the Mac OS and would appreciate any suggestions/directions!

Last login: Thu Sep  8 15:07:04 on ttys001
LSLaptop:~ lrs$ '/Applications/'/sage --notebook
Traceback (most recent call last):
  File "/Applications/", line 3, in <module>
    import os, sys, socket
  File "/Applications/", line 46, in <module>
    import _socket
ImportError: No module named _socket
edit retag flag offensive close merge delete

10 Answers

Sort by » oldest newest most voted

answered 2011-09-08 22:07:16 +0200

niles gravatar image

updated 2011-09-12 09:28:52 +0200

There are known problems with Sage on Lion, but the Sage binary compiled for Snow Leopard (Mac OS 10.6) has been reported to work on Lion.

However, there may be an incompatibility with the .app wrapper instead of the underlying Sage program . . . can you let us know the result of opening Sage on the command line? Try opening the Terminal (Applications -> Utilities -> Terminal) and pasting in the following:


Does that give you a "sage:" prompt, or result in more errors?

Updates: Ok; @jholtzman, it looks like you are having trouble with iPython; I'm not sure why. Which version of Sage did you install?

@Louisa Grey, it looks like you're getting the expected output; does the notebook start when you type "notebook()" at the "sage:" prompt? If so, I would say that Sage is working, but the .app wrapper is not.

edit flag offensive delete link more


That command produces the following result: ---------------------------------------------------------------------- | Sage Version 4.7.1, Release Date: 2011-08-11 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- Traceback (most recent call last): File "/Applications/", line 18, in <module> import IPython ImportError: No module named IPython

jholtzman gravatar imagejholtzman ( 2011-09-10 14:59:11 +0200 )edit

Huh. That's not a good sign, though at least it's not the app. Would you be able to try the 32-bit version for Snow Leopard (if there is one)? I realize that's a little much to ask.

kcrisman gravatar imagekcrisman ( 2011-09-10 21:46:04 +0200 )edit

Thank you so much for your help. On my machine I did get a "sage:" prompt (after some other text, pasted below) & was then able to start the notebook, so it looks like I'm good to go. If there's anything else you would like me to try/ any info you want me to send, I'd be glad to help- LSLaptop:~ lrs$ /Applications/ ---------------------------------------------------------------------- | Sage Version 4.7.1, Release Date: 2011-08-11 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- Setting permissions of DOT_SAGE directory so only you can read and write it. sage:

Louisa Grey gravatar imageLouisa Grey ( 2011-09-11 18:49:10 +0200 )edit

@niles, the notebook did start when I typed notebook() at the sage: prompt. Now I just have to learn how to use it :)

Louisa Grey gravatar imageLouisa Grey ( 2011-09-12 09:44:34 +0200 )edit

@Loisa Can you run `/Applications/ /Applications/ ~/sageapp.log` since that's a script used by the app to actually start sage. That will help narrow down the problem.

Ivan Andrus gravatar imageIvan Andrus ( 2011-11-17 10:58:32 +0200 )edit

answered 2011-09-22 01:10:06 +0200

Charlie Martin gravatar image

Folks, I've had a similar problem. Downloaded the, tried launching it, then (as suggested here) tried launching from the command line. Here are the results:

209 $ /Applications/
| Sage Version 4.7.1, Release Date: 2011-08-11                       |
| Type notebook() for the GUI, and license() for information.        |
Traceback (most recent call last):
  File "/Volumes/sage-4.7.1-OSX-64bit-10.6-x86_64-Darwin/", line 18, in <module>
    import IPython
ImportError: No module named IPython
210 $

iPython is installed in my normal Python world.

edit flag offensive delete link more


Just confirming this story if it helps. I did exactly as Charlie Martin has done with exactly the same results. I am working on new hardware (Macbook Air running OSX10.7) so this is a fresh factory install of OSX, not an upgrade.

Andrew Francis gravatar imageAndrew Francis ( 2011-10-17 16:50:38 +0200 )edit

I am also experiencing the same difficulty.

sflammia gravatar imagesflammia ( 2011-11-14 15:03:19 +0200 )edit
kcrisman gravatar imagekcrisman ( 2011-11-16 22:23:20 +0200 )edit

Sage supplies its own instance of ipython. So you don't need to have it installed separately.

Dima gravatar imageDima ( 2011-11-18 23:25:53 +0200 )edit

Right, but why is his Sage ipython not importing?

kcrisman gravatar imagekcrisman ( 2011-11-19 07:33:17 +0200 )edit

answered 2012-01-15 14:19:16 +0200

brunoh gravatar image

updated 2012-01-15 14:21:54 +0200

I had exactly the same problem than@Louisa Grey with the "no module named _socket"

I found the following solution :

1- install the 2.7 version of Python for OSX

2- go into the easy_install directory and type "sudo easy_install-2.7 iPython" in a Terminal bash

3- again in the same Terminal session, type "sudo easy_install readline"

then it worked fine

edit flag offensive delete link more


Worked for me with the latest version of Python and just running: "sudo easy_install iPython" and then "sudo easy_install readline".

MonsieurDart gravatar imageMonsieurDart ( 2012-02-15 11:38:43 +0200 )edit

answered 2011-11-24 01:58:09 +0200

tellif gravatar image

I had the same problem on lion (2011 MBA). I fixed it by going to python's website, downloading, and installing the latest version, as the base version of python installed on OSX is very far behind. Hope this helps!

edit flag offensive delete link more


If you could tell us *exactly* what you did, that would be helpful. In principle, the system Python should be irrelevant, but maybe for the app it isn't?

kcrisman gravatar imagekcrisman ( 2011-12-15 13:18:34 +0200 )edit

answered 2013-02-22 19:45:56 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.


I have installed the Sage 5.6 - OSX 10.6 on my Mac with OSX 10.7 Lion. It works pretty well until I decide to use sagetex (with TeXShop). And some problems arise: 1) I can't have the notebook anymore with safari (error message: 'can't connect to localhost:8000') while sage in the terminal works properly; 2) when I run the SageTest.sagetex.sage, I got this message:

File "/Users/janyphiphi/Library/TeXShop/Engines/Inactive/Sage/", line 19, in <module> _st_.endofdoc() File "/Applications/", line 282, in endofdoc sagef = open(self.filename + '.sagetex.sage', 'r') IOError: [Errno 2] No such file or directory: 'SageTest.sagetex.sage' logout

Any idea?

I'm french and beginner in terminal , python, and so on, so, be pretty, be clear, as far as possible! Thanks a lot

edit flag offensive delete link more


Hi, you probably will want to open a new question with this, as you are able to use Sage and the problems are different than those above. Just FYI, the notebook should now be using port 8080, but the automatic login should still be working... anyway, put more details on a new question, or on the sage-support mailing list! Good luck.

kcrisman gravatar imagekcrisman ( 2013-02-22 22:08:59 +0200 )edit

answered 2011-12-23 11:08:10 +0200

Found the problem with the "RuntimeError: no available port." issue.

The key is:

   File "<ipython console>", line 1
     b Integer(134)
SyntaxError: invalid syntax

The mac version, for whatever reason is expecting the port arg as a string, not an int.

This works:

sage: notebook(port="8000")

Note the quotes around the port number.

edit flag offensive delete link more

answered 2011-11-16 18:59:34 +0200

I am having precisely these problems also. I'm new to Sage, looking forward to learning how to use it.

Using the binaries on Lion 10.7.2, with xcode 4.2, the latest iPython (32 I think), I'm able to get sage to start, with menus. The terminal shows the errors noted above. No sage prompt. When I try to open the notebook, I get the error "could not connect to localhost:8000" which I'm presuming means the server did not start.

I was considering trying to build it myself, but I've looked at the build problems in, and I think I'll just wait to see how it goes, obviously there are a lot of little hidden nasties in the new versions of OS X and xcode to deal with.

Kind Regards, Michael Hund

edit flag offensive delete link more


You can fix the localhost:8000 notebook error by opening up /Sage/devel/ext/sage/ext/mac-app/Sage.xcodeproj in XCode, opening file AppController.m and changing line 61 from 'port=8000' to 'port=8080', then recompiling and moving /Sage/devel/ext/sage/ext/mac-app/build/Debug/ (or /Release if you speficied that in XCode) to your applications folder.

HHammond gravatar imageHHammond ( 2013-02-19 21:37:56 +0200 )edit

answered 2011-11-18 23:29:15 +0200

just to confirm, does a non-app version of Sage, i.e. sage-4.7.2-OSX-64bit-10.6-x86_64-Darwin.dmg work for you? My understanding is that it should work. The only inconvenience is that you have to start it from Terminal...

edit flag offensive delete link more


you can also make a handy app using automator to run the following shell script: "/Applications/sage/sage -notebook". That way you can run sage from the Finder

sam_roberson gravatar imagesam_roberson ( 2012-02-21 01:02:34 +0200 )edit

answered 2011-12-15 05:21:23 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

I had the same problem. I installed Xcode and the latest python 2.7. It still didn't work until I did a manual run with


Now it works fine with the app or with automatic startup. I don't know if it needed Xcode or new Python or if the manual start was enough to get it working.

edit flag offensive delete link more


Those things shouldn't matter, assuming that you didn't actually *use* Xcode or the system Python (say, to build something). Strange that one of the other comments found this helped...

kcrisman gravatar imagekcrisman ( 2011-12-15 13:17:52 +0200 )edit

answered 2011-12-23 01:43:35 +0200

Here's my Lion attempt:

1 %> /Applications/              
| Sage Version 4.7.2, Release Date: 2011-10-29                       |
| Type notebook() for the GUI, and license() for information.        |
sage: notebook()
The notebook files are stored in: sage_notebook.sagenb
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (97, 0))

RuntimeError                              Traceback (most recent call last)

/Users/bedge/.sage/<ipython console> in <module>()

/Applications/ in __call__(self, *args, **kwds)
    215     """
    216     def __call__(self, *args, **kwds):
--> 217         return self.notebook(*args, **kwds)
    219     notebook = run_notebook.notebook_twisted
/Applications/ in notebook_twisted(self, directory, port, interface, address, port_tries, secure, reset, accounts, require_login, server_pol, ulimit, timeout, open_viewer, sagetex_path, start_path, fork, quiet, subnets)
    441             print "*" * 70
--> 443     port = find_next_available_port(interface, port, port_tries)
    444     if open_viewer:
    445         "Open viewer automatically isn't fully implemented.  You have to manually open your web browser to the above URL."

/Applications/ in find_next_available_port(interface, start, max_tries, verbose)
    132             print "Port %s is already in use."%port
    133             print "Trying next port..."
--> 134     raise RuntimeError, "no available port."

RuntimeError: no available port.
Exiting Sage (CPU time 0m0.69s, Wall time 0m27.68s).
1 22:41:43 bedge@tmacc  ~/personal/sage

and my python info:

0 %> python
Python 2.7.2 (default, Aug 11 2011, 14:59:27) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
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



Asked: 2011-09-08 17:35:30 +0200

Seen: 4,872 times

Last updated: Feb 22 '13