Ask Your Question

Error: Starting sage in the eclipse IDE (linux, after sage -sh in terminal, followed by eclipse &, and using pyDev plugin) - Error: Unable to get info on the interpreter

asked 2017-04-18 05:25:15 -0500

dan_fulea gravatar image

updated 2017-04-18 11:48:32 -0500

Some years ago, there was a good possibility to start sage in eclipse and develop code with a better immediate feed back, and syntax highlight. (emacs can do this too, but...) The debug support makes it also possible to be quick and efficient, it is the main reason i need eclipse.

It still works on my very old computers running Ubuntu or mint and an old eclipse.

Now the situation has changed, after eclipse "improved" the install process by additional checkings.

The interpreter sage cannot be defined, for some check cannot be performed.

What am i doing?

In a terminal, the right sage settings are published via:

sage -sh

Then from the command line:

[dan@... ~]$ sage -sh

Starting subshell with Sage environment variables set.  Don't forget
to exit when you are done.  Beware:
 * Do not do anything with other copies of Sage on your system.
 * Do not use this for installing Sage packages using "sage -i" or for
   running "make" at Sage's root directory.  These should be done
   outside the Sage shell.

Bypassing shell configuration files...

Note: SAGE_ROOT=/usr
(sage-sh) dan@...:~$ eclipse &
[1] 31490
(sage-sh) dan@...:~$ org.eclipse.m2e.logback.configuration: The org.eclipse.m2e.logback.configuration bundle was activated before the state location was initialized.  Will retry after the state location is initialized.

... and so on ...

(sage-sh) dan@... :~$ uname -a
Linux ... 4.9.20-1-MANJARO #1 SMP PREEMPT Fri Mar 31 20:42:21 UTC 2017 i686 GNU/Linux

In eclipse neon, there is no chance to configure the interpreter for the executable:

(sage-sh) dan@... :~$ which sage

via PyDev > Python Interpreter > New > ...

And the reason is (typed by own hands, since copy+paste does not work):

Unable to get info on the interpreter: /usr/bin/sage

Common reasons include...

and so on.

Does anybody have a solution to this issue? Thanks in advance!

Note: Yes, it is possible to configure the interpreter located at /usr/bin/sage-python, but then there is still some yoga needed, almost every fifth line written has to be changed, e.g. 2^3 into 2 ** 3 and R.<X> = QQ[] into R = PolynomialRing( QQ, name='X' ) and so on...

edit retag flag offensive close merge delete


Just to note that if you use that then you lose all the preparsing, some of which is quite annoying not just for entry - for instance, the 2**3 will probably not be using Sage integers.

kcrisman gravatar imagekcrisman ( 2017-04-19 07:06:07 -0500 )edit

@kcrisman thanks, yes this is often the problem.

dan_fulea gravatar imagedan_fulea ( 2017-04-24 11:35:04 -0500 )edit

The error has the following Details >>

See error log for details.
Unable to recreate the Interpreter info (Its format changed. Please, re-create your Interpreter information).Contents found:sage-run received unknown option: -u
usage: sage [options]
Try 'sage -h' for more information.
dan_fulea gravatar imagedan_fulea ( 2017-04-24 11:35:37 -0500 )edit

The file /usr/bin/sage-run has the following content:

#!/usr/bin/env python2

import os, sys
from subprocess import call

if len(sys.argv) < 2:
    print("You must give a file argument")

fn = sys.argv[1]
opts = sys.argv[2:]

if fn.startswith('-'):
    print("sage-run received unknown option: {}".format(fn))
    print("usage: sage [options]")
    print("Try 'sage -h' for more information.")

and further lines. It seems that this is the reason for the error.

dan_fulea gravatar imagedan_fulea ( 2017-04-24 11:47:45 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-04-24 12:11:30 -0500

dan_fulea gravatar image

Of course that -- after finding the sage-run executable as in the above comment -- the solution was simple.

After commenting the obstacle if block in the /usr/bin/sage-run file as here:

# if fn.startswith('-'):
#     print("sage-run received unknown option: {}".format(fn))
#     print("usage: sage [options]")
#     print("Try 'sage -h' for more information.")
#     sys.exit(1)

the following sample program was working in eclipse with the eclipse-python-project-interpreter pointing to /usr/bin/sage

# inside eclipse started from a terminal, where previously sage -sh was typed
from sage.all import *    

E = EllipticCurve( GF(2017), [1,0,0,0,1] )

print E.order()
print E.random_point()

This gave in the eclipse console:

(1551 : 114 : 1)

And the eclipse method extension worked immediately after typing EllipticC .

Although for the random_ there was no proposal (in time).

This works for me, so i'll validate the post - if no complains arrive next days.

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

1 follower


Asked: 2017-04-18 05:25:15 -0500

Seen: 249 times

Last updated: Apr 24