How reach octave or Macaulay2 from Sage notebook?
Enviroment: With SageMath 9-6-1.4.2 (arm64 architecture) under macOS 12.5.1 on an M1 Mac, I cannot directly access either octave or Macaulay2.
- Octave is in
/opt/local/bin
and the Macaulay2 executableM2
is in/Applications/Macaulay2-1.20/bin
. - Both paths were already in the path exported from my
.profile
(this is relevant to possible workarounds #1, below). - I can run both
M2
andoctave
successfully from a Terminal command-line.
Problems: Octave: In the jupyter notebook (with the SageMath 9.6 kernel running, I evaluated:
octave.eval('2+2')
The long error that ensued included:
RuntimeError: unable to start octave because the command "octave-cli --no-line-editing --silent --eval 'PS2(PS1());more off' --persist" failed: The command was not found or was not executable: octave-cli.
Similarly, when I evaluated
macaulay2('3/5 + 7/11')
I get a long error message that includes:
TypeError: unable to start macaulay2 because the command 'M2 --no-debug --no-readline --silent -e \'sageLoadMode = false;ZZ#{Standard,Core#"private dictionary"#"InputPrompt"} = ZZ#{Standard,Core#"private dictionary"#"InputContinuationPrompt"} = lineno -> if(sageLoadMode) then "_EGAS_LOAD_ : " else "_EGAS_ : ";printWidth = 0;lineNumber = 10^9;sageAssign = (k, v) -> (if not instance(v, Sequence) then use v; k <- v);\'' failed: The command was not found or was not executable: M2.
Possible workarounds:
- The method described in https://ask.sagemath.org/question/794...: This does not work for me, as it now causes
SageMath-9-6.app
not to open at all. (Since the current executable inside theSageMath-9-6.app
package is namedSageMath
rather thanSage
,I did change
Sageto
SageMathfor the name of the added shell script, in the last line of that shell script, and as the value of
CFBundleExecutablein
info.plist`). - The method described in the first comment at https://ask.sagemath.org/question/571...:
For Macaulay2, this sort of thing does work:
m2=Macaulay2(command='/Applications/Macaulay2-1.20/bin/M2')
m2('3/5+7/11')
For Octave:
oc=octave(command='/opt/local/bin/octave')
This does not work! Error:
TypeError Traceback (most recent call last)
/var/folders/r2/v_ly_rjj6_v1qpzx4kqy_mqr0000gn/T/ipykernel_4852/1477866728.py in <module>
----> 1 oc=octave(command='/opt/local/bin/octave')
TypeError: Interface.__call__() got an unexpected keyword argument 'command'
QUESTIONS:
(a) the workaround 2 for the call to Macaulay2 seems awkward. How can one take care of the path issue transparently?
(b) how make the call to octave work, too?
You could try
Octave(command=/opt/local/bin/octave-cli)
(capital O). You could also try setting the environment variableSAGE_OCTAVE_COMMAND
to/opt/local/bin/octave
or maybe even better,/opt/local/bin/octave-cli
(if that exists). What doesos.environ['PATH']
return?