Ask Your Question
1

SageMath Scilab interface not working

asked 2018-03-10 18:33:35 -0500

danielvolinski gravatar image

I am working with SageMath 8.1 on Windows 10 Native with Jupyter Notebook.

I try to issue the following command

sage: scilab.eval('2+2')

I get RuntimeError: unable to start scilab because the command 'scilab -nw' failed: The command was not found or was not executable: scilab.

I put the bin directory of Scilab on the %PATH% environment Variable.

I open a DOS Terminal and I see it in my PATH like this: C:\Program Files\scilab-6.0.1\bin

I open a Sage Terminal and I see it in my PATH like this: /cygdrive/c/Program Files/scilab-6.0.1/bin

I issue the following command in the Sage Terminal: /cygdrive/c/Program Files/scilab-6.0.1/bin/scilab -nw but I get bash: /cygdrive/c/Program: No such file or directory

Please advice.

Daniel

edit retag flag offensive close merge delete

Comments

I wonder whether this is a bigger issue of using outside software in the Windows solution.

kcrisman gravatar imagekcrisman ( 2018-03-10 19:53:57 -0500 )edit

I don't know if R is delivered with SageMath 8.1 or it is using the one I installed, but the interface with R is working fine.

danielvolinski gravatar imagedanielvolinski ( 2018-03-11 01:23:00 -0500 )edit

The R interface is always tested because it's part of Sage, so it's not interfaces. Scilab is a fairly optional interface and hence not as tested and hence possibly broken ...

kcrisman gravatar imagekcrisman ( 2018-03-13 21:36:11 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2018-03-11 03:27:46 -0500

slelievre gravatar image

updated 2018-03-19 19:14:46 -0500

Regarding the last error in the question:

I issue the following command in the Sage Terminal: /cygdrive/c/Program Files/scilab-6.0.1/bin/scilab -nw but I get bash: /cygdrive/c/Program: No such file or directory

As @Emmanuel Charpentier mentions, you should escape the space character in "Program Files".

That is, in the Sage shell, you should instead run

/cygdrive/c/Program\ Files/scilab-6.0.1/bin/scilab -nw

Note that the bash error

bash: /cygdrive/c/Program: No such file or directory

is an indication: because of the space, bash thought you were calling /cygdrive/c/Program rather than /cygdrive/c/Program\ Files/scilab-6.0.1/bin/scilab.

The same goes for setting the PATH in the Sage shell. What you need to add to this PATH is

/cygdrive/c/Program\ Files/scilab-6.0.1/bin

with the space in "Program Files" escaped with a backslash.

Now if you want to use Scilab from within Sage (in the Sage REPL or in the Jupyter notebook), that's it.

If you want to run the Scilab kernel for Jupyter, you should install it.

For that, in a Sage shell, run

pip install scilab_kernel

or

sage -pip install scilab_kernel

This will install the Scilab kernel, which will be located at

$SAGE_ROOT/local/share/jupyter/kernels/scilab

where $SAGE_ROOT is the location of the Sage installation.

It also installs a scilab_kernel module in Sage's Python, located in

$SAGE_ROOT/local/lib/python2.7/site-packages/scilab_kernel

Go edit line 93 of the file

$SAGE_ROOT/local/lib/python2.7/site-packages/scilab_kernel/kernel.py

and change it from

        executable = self.executable + ' -nw'

to

        executable = self.executable + ' -nwni'

Next time you launch Sage's Jupyter notebook server, you will be able to create Jupyter worksheets with the Scilab kernel, or to change kernel to the Scilab kernel in existing Jupyter worksheets.

edit flag offensive delete link more

Comments

I successfully did the sage -pip install scilab_kernel

I launched Sage's Jupyter Notebook server and now I can create a Jupyter worksheets with the Scilab kernel. The problem now is that the kernel dies immediately when I click on the first cell. It offers to restart the kernel, which a do, but then it dies again. Sometimes the kernel dies after a few second without me doing anything!

danielvolinski gravatar imagedanielvolinski ( 2018-03-11 05:11:01 -0500 )edit

I proceeded to uninstall Scilab and install it on a folder with no spaces. I updated the path environment variable accordingly. I opened a sagemath notebook and run a scilab command, I got the same error as before. I opened a scilab notebook and the same as before, the kernel dies almost immediately.

danielvolinski gravatar imagedanielvolinski ( 2018-03-11 14:09:15 -0500 )edit

I edited my answer, adding the following lines:

It also installs a scilab_kernel module in Sage's Python, located in

$SAGE_ROOT/local/lib/python2.7/site-packages/scilab_kernel

Go edit line 93 of the file

$SAGE_ROOT/local/lib/python2.7/site-packages/scilab_kernel/kernel.py

and change it from

        executable = self.executable + ' -nw'

to

        executable = self.executable + ' -nwni'

Please give it a try and report back!

slelievre gravatar imageslelievre ( 2018-03-19 19:15:45 -0500 )edit

I did the changes you suggest, but nothing changed: The Jupyter Notebook with SageMath 8.1 kernel and the command sage: scilab.eval('2+2') still complains about not been able to find scilab -nw and the Jupyter Notebook with the Scilab kernel dies almost immediately.

I noticed there is a kernel.pyc, which has binary code, in the same directory as kernel.py. Its timestamp is after the change in kernel.py so it seems to be compiled correctly.

Daniel

danielvolinski gravatar imagedanielvolinski ( 2018-03-20 04:50:22 -0500 )edit

I installed SageMath 8.2 on Windows 10 Native, then installed scilab_kernel but the problem still remains: the kernel dies almost immediately after opening a new Jupiter Notebook with the scilab kernel.

danielvolinski gravatar imagedanielvolinski ( 2018-05-16 13:35:11 -0500 )edit
1

answered 2018-03-11 01:22:04 -0500

Emmanuel Charpentier gravatar image

updated 2018-03-11 01:22:47 -0500

I'v been bitten by this one more than once in Cygwin...

You have to quote paths containing spaces. The trick is to use Windows-style quotation for arguments going to cmd.exe and Unix-style quotation for arguments going to bash.exe or other Cygwin programs...

For example, from a bash session I'd try to invoke your Windows Scilab as :

/cygdrive/c/Program\ Files/scilab-6.0.1/bin/scilab -nw`

(note the backslash quoting the space in Program Files).

HTH,

edit flag offensive delete link more

Comments

I implemented your suggestion and I get

$ '/cygdrive/c/Program Files/scilab-6.0.1/bin/scilab -nw' bash: /cygdrive/c/Program Files/scilab-6.0.1/bin/scilab -nw: No such file or directory

or

$ '/cygdrive/c/Program Files/scilab-6.0.1/bin/scilab.bat -nw' bash: /cygdrive/c/Program Files/scilab-6.0.1/bin/scilab.bat -nw: No such file or directory

BTW, the command scilab -nw in a DOS Window works fine.

But this is not my main concern: I want to use Scilab in the Jupyter Notebook, what should I do?

Daniel

danielvolinski gravatar imagedanielvolinski ( 2018-03-11 01:55:38 -0500 )edit
1

1) You are quoting the space between scilab and -nw, therefore trying to execute a program named scilab -nw (with a space inb its name), which doesn't exist. Try either :

'/cygdrive/c/Program Files/scilab-6.0.1/bin/scilab' -nw

or

/cygdrive/c/Program\ Files/scilab-6.0.1/bin/scilab -nw

I _told_ you quoting was tricky with Cygwin (and otherwise, BTW)...

2) As slelievre said, if you want to use Scilab directly (not through Sage), you have to install its kernel. But that's not what you asked for initially (your example uses the Sage-Scilab interface)... I'm still running H. sapiens sapiens L. V 1.0 (i. e. no telepathic interface), and couldn't guess this...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2018-03-11 04:09:37 -0500 )edit

Fwiw there's nothing Cygwin-specific about that. True in any POSIX shell (which is why UNIX programs generally avoid spaces in anything, though it's true it's more of a problem on Cygwin since Windows programs do not avoid spaces as much...)

Iguananaut gravatar imageIguananaut ( 2018-05-14 06:03: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

1 follower

Stats

Asked: 2018-03-10 18:33:35 -0500

Seen: 80 times

Last updated: Mar 19