Ask Your Question
0

SageMath cannot access Mathematica

asked 2019-11-17 06:41:42 -0500

bekalph gravatar image

updated 2019-11-17 07:08:01 -0500

I have installed Mathematica Version 11.3 at a Linux system (openSUSE Leap 15.1) on a partition "math", i.e. separated from the Linux home and system partition. I have tried to send Mathematica expressions from SageMath to Mathematica in the manner described in the SageMath reference by using a SageMath Notebook or its command line interface. They are rejected with:

TypeError: unable to start mathematica: End Of File (EOF). Exception style platform. Mathematica finished running /usr/bin/sh -c stty -echo; math -rawterm command: /usr/bin/sh args: ['/usr/bin/sh', '-c', 'stty -echo; math -rawterm'] buffer (last 100 chars): '' before (last 100 chars): 'es/Linux/WolframKernel\r\nnot found. Your Mathematica installation may be i incomplete\r\nor corrupted.\r\n' after: <class 'pexpect.exceptions.eof'="">

In the course of the installation of Mathematica I added the path to the math command line interface of Mathematica to the common PATH-sequence. Therefore I am able to access the Mathematica command line interface by simply entering math or the command:

/usr/bin/sh -c stty -echo; math -rawterm

using a bash-terminal outside SageMath. I have checked that I can do it without the need for specifying the complete path to math. However, entering the same command within a Sage-session by using the Python's OS- interface is only successful if the full path to math is specified:

/usr/bin/sh -c stty -echo; /run/media/bernhardi/math/math -rawterm

The error appearing otherwise is the same as that one returned by the above described trials to send mathematica objects. The protocol shows that the mathematica objects are sent to Mathematica without detailed path info. Thus, obviously the SageMath-Mathematica interface does not recognize the complete path info that is availabe in the basic Linux system. Maybe the missing info is caused by the fact that Mathematica is located on a remote partition. Therefore my question: Is it possible to provide sageMath with the needed full path to math?

Unfortunately it is not possible to attach the complete output of SageMath.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-11-17 12:44:23 -0500

eric_g gravatar image

updated 2019-11-17 13:14:54 -0500

Could you try the following:

Open a bash-terminal and set the following environment variable:

export SAGE_MATHEMATICA_COMMAND="/run/media/bernhardi/math/math -rawterm"

Then run SageMath from that terminal (either in console or notebook mode) and try some Mathematica command. If this works, you might add the above export command at the end of your .bashrc file.

Comment: I am not using Mathematica and don't have it installed on my computer; I came to this answer by taking a look at the source code of SageMath's mathematica command, which one can easily access via the double question mark (it's so nice to be open-source ;-) ):

sage: mathematica??
edit flag offensive delete link more

Comments

It works! Many many thanks for your help. I suggerst to include this important advice in the official sageMath documentation.

bekalph gravatar imagebekalph ( 2019-11-17 13:02:42 -0500 )edit

I am glad that it works. Actually this looks like a bug to me: this should work without the need to set up this environment variable by hand. I am waiting for the feedback from other Sage devs to see if we should open a ticket about it. Meanwhile, I am editing the answer to tell how I came to this workaround.

eric_g gravatar imageeric_g ( 2019-11-17 13:07:55 -0500 )edit

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: 2019-11-17 06:41:42 -0500

Seen: 148 times

Last updated: Nov 17 '19