ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 29 Aug 2022 21:44:54 +0200How reach octave or Macaulay2 from Sage notebook?https://ask.sagemath.org/question/63845/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 executable `M2` 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` and `octave` 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:**
1. The method described in https://ask.sagemath.org/question/7949/running-octave-from-the-sage-notebook/?answer=28684#post-id-28684: This does *not* work for me, as it now causes `SageMath-9-6.app` not to open at all.
(Since the current executable inside the `SageMath-9-6.app` package is named `SageMath` rather than `Sage`,`I did change `Sage` to `SageMath` for the name of the added shell script, in the last line of that shell script, and as the value of `CFBundleExecutable` in `info.plist`).
2. The method described in the first comment at https://ask.sagemath.org/question/57112/cant-run-macaulay2-via-sagemath-in-jupyter-notebook/:
For Macaulay2, this sort of thing *does* work:
<code>m2=Macaulay2(command='/Applications/Macaulay2-1.20/bin/M2')<br>
m2('3/5+7/11')</code>
For Octave:
<code>oc=octave(command='/opt/local/bin/octave')</code>
This does *not* work! Error:
<code>TypeError Traceback (most recent call last)<br>
/var/folders/r2/v_ly_rjj6_v1qpzx4kqy_mqr0000gn/T/ipykernel_4852/1477866728.py in <module><br>
----> 1 oc=octave(command='/opt/local/bin/octave')<br>
<br>
TypeError: Interface.__call__() got an unexpected keyword argument 'command'</code>
**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?murrayeMon, 29 Aug 2022 19:27:29 +0200https://ask.sagemath.org/question/63845/Adding path entries in kernel.json does not workhttps://ask.sagemath.org/question/63846/adding-path-entries-in-kerneljson-does-not-work/According to comment 5 at https://trac.sagemath.org/ticket/31773, the following edited kernel.json ought to make both octave and Macaulay2's M2 available to the jupyter kernel in a SageMath jupyter notebook session:
<code>{"argv": ["/var/tmp/sage-9.6-current/venv/bin/sage", "--python", "-m", "sage.repl.ipython_kernel", "-f", "{connection_file}"], "display_name": "SageMath 9.6", "language": "sage", "env": {"PATH":"/Applications/Macaulay2-1.20/bin:/opt/local/bin:$PATH"}}</code>
Nonetheless, after this change and a fresh restart of SageMath-9.6.app, neither `octave` nor `macaulay2` work there.
Environment: SageMath-9.6-1.4.2 arm64 version under macOs 12.5.1 on an M1 Mac.
How fix?
Related:
https://ask.sagemath.org/question/7949/running-octave-from-the-sage-notebook/?answer=28684#post-id-28684
https://ask.sagemath.org/question/63845/how-reach-octave-or-macaulay2-from-sage-notebook/murrayeMon, 29 Aug 2022 21:44:54 +0200https://ask.sagemath.org/question/63846/using sage functions with data from octavehttps://ask.sagemath.org/question/8188/using-sage-functions-with-data-from-octave/Hello, I´m trying to construct a histogram using octave within sage, but I don´t know how to use sage functions with data that comes from octave, here´s what I´m doing:
a = octave.normrnd(50,3,100,1) #this generates a column vector with normal random data
b = octave.hist(a) #this generates a histogram from the previous data
bar_chart(b) # this is where I get the following error:
NotImplementedError: Unable to parse output
Is this something that has not been implemented as the message suggests or am I doing something wrong?jamlatinoMon, 27 Jun 2011 17:28:39 +0200https://ask.sagemath.org/question/8188/More digits from octavehttps://ask.sagemath.org/question/34187/more-digits-from-octave/ Hi, how can I get all the 15/16 digits from a command like pi = octave('pi')?
Marco CaliariFri, 22 Jul 2016 12:37:53 +0200https://ask.sagemath.org/question/34187/error when perform symbolic calculation in Octave of Sagehttps://ask.sagemath.org/question/32507/error-when-perform-symbolic-calculation-in-octave-of-sage/ I have tried the Octave (matlab-like) kernel in Sagemathcloud, but when I intended to perform the symbolic calculation in Octave, something strange happened, and I can't solve it.
My code is as follows:
pkg load symbolic
syms x
f = sin(x)^2;
diff(f)
when I execute it, error happened, it said
> 'ascii' codec can't encode character u'\u22c5' in position 13: ordinal not in range(128)
How can I solve this problem?wangyanTue, 09 Feb 2016 11:44:25 +0100https://ask.sagemath.org/question/32507/cell arrays octavehttps://ask.sagemath.org/question/31485/cell-arrays-octave/Sorry my question probably naive. I have vector K with numbers.
K =
92
93
109
110
114
115
143
147
161
162
I have also a cell-array
C =
{
[1,1] = 4
[2,1] = 2
[3,1] = 5
[4,1] = 9
[5,1] = 7
[6,1] = 6
[7,1] = 8
[8,1] = 1
[9,1] = 3
[10,1] = 10
}
I need to compose the vector with values from K in C order.
I can do it using K([4,2,5,9,7,6,8,1,3,10]), but how to write it using a variable. Thank you very much.ivan.bFri, 11 Dec 2015 16:38:04 +0100https://ask.sagemath.org/question/31485/runs in Octave (tested) but not SageMathCloud (errors)https://ask.sagemath.org/question/30334/runs-in-octave-tested-but-not-sagemathcloud-errors/Hi, this is my assignment in numerical mathematics, this runs in Octave
but unfortunately not in SageMath, can someone see what the problem is?
See the SageMathCloud worksheet
https://cloud.sagemath.com/projects/666fc8f9-8619-46f9-b41d-c85afdef2169/files/2015-10-29-090250.sagews
Here is the code
# a)
function y=f(x)
y=3/(2+x)
endfunction
function a=p(x)
y1=x^2
y2=x
y3=1
a=[y1,y2,y3]
endfunction
# b)
# Stützstellen vector x
x=[-1 0 1]
f(x(1))
f(x(2))
f(x(3))
# Anzahl der Stützstellen bestimmer
d=length(x)
A=zeros(d,d)
for i=1:3
A(i,:)=p(x(i))
endfor
b=zeros(3,1)
for i=1:3
b(i)=f(x(i))
endfor
b
[L,U,P] = lu(A)
invL=inv(L)
y=invL*P*b
invU=inv(U)
z=invU*y
A*z
b
thethaThu, 29 Oct 2015 09:17:20 +0100https://ask.sagemath.org/question/30334/Converting Octave vector to Sage listhttps://ask.sagemath.org/question/10159/converting-octave-vector-to-sage-list/I have a Sage notebook that combines Sage and Octave code. How can I make the output of the Octave code (a vector) available to Sage as a list or vector?jaiaMon, 27 May 2013 22:32:02 +0200https://ask.sagemath.org/question/10159/Running octave from the sage notebookhttps://ask.sagemath.org/question/7949/running-octave-from-the-sage-notebook/I'm trying to run octave through the sage notebook. When I try to evaluate a cell (e.g. x = linspace(0,1,100)), I get the error message:
RuntimeError: Unable to start octave
Examining the traceback in more detail doesn't point to anything that suggests how to fix the problem, and I was wondering whether anyone else had this problem. Octave is installed on my computer, and runs fine from the command line. Can anyone help me with this? Thanks in advance!RickWed, 16 Feb 2011 14:40:16 +0100https://ask.sagemath.org/question/7949/plot in Octavehttps://ask.sagemath.org/question/23242/plot-in-octave/To add context as requested by kcrisman, I am using Octave in Cloud.Sagemath.com running scripts in .m files.
How does one plot in Octave? Supposedly the command should be the same as in Matlab, e.g.
x = 1:10;
figure, plot(x,x.^2)
However, nothing showed up in the terminal. Please help.HansMon, 07 Jul 2014 04:50:03 +0200https://ask.sagemath.org/question/23242/Debugging environment and GUIhttps://ask.sagemath.org/question/11072/debugging-environment-and-gui/Is there a debugging GUI/environment within SageMathCloud where one can set breakpoints and step through code across different files, for Sage and Octave?HansSun, 15 Jun 2014 12:24:26 +0200https://ask.sagemath.org/question/11072/Can I use Sage as Octave creating a figure showing and holding it on while adding points?https://ask.sagemath.org/question/9755/can-i-use-sage-as-octave-creating-a-figure-showing-and-holding-it-on-while-adding-points/Hello,
I am new of Sage. It seems pretty powerful. I tested the virtual machine in Windows but some doubts remains.
I would like to replace my programs written in octave, that are plotting the kinematics of an object during time.
I would like to popup a figure and changing the content of it in a for loop.
E.g., something like this should be possible
figure(1)
hold on
for i=1:10
plot(i, i^2)
sleep(1)
end
hold off
How can I replot on the same figure in Sage Network?
If I use the interactive shell from the virtual machine I obviously can plot no more.
Regards,
MauroMalloThu, 31 Jan 2013 10:34:30 +0100https://ask.sagemath.org/question/9755/Octave works in command line but not in notebookhttps://ask.sagemath.org/question/8532/octave-works-in-command-line-but-not-in-notebook/Hello,
"octave" runs runs from terminal, so $PATH seems to be correct. Moreover, octave calls from the sage console also work fine. But, octave calls from a notebook running on localhost return what I have pasted below.
Any suggestions?
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_61.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("b2N0YXZlLmV2YWwoJzIrMicp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/private/var/folders/wR/wRRw4W7cHX8BD5dByW-jjk+++TI/-Tmp-/tmpzS3ZG9/___code___.py", line 2, in <module>
exec compile(u"octave.eval('2+2')" + '\n', '', 'single')
File "", line 1, in <module>
File "/Users/epenn/Math/Apps/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1039, in eval
for L in code.split('\n') if L != ''])
File "/Users/epenn/Math/Apps/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 671, in _eval_line
self._start()
File "/Users/epenn/Math/Apps/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/interfaces/octave.py", line 284, in _start
Expect._start(self)
File "/Users/epenn/Math/Apps/Sage-4.7.2-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 458, in _start
raise RuntimeError, "Unable to start %s"%self.name()
RuntimeError: Unable to start octaveepennMon, 05 Dec 2011 20:07:33 +0100https://ask.sagemath.org/question/8532/Can octave call a c function?https://ask.sagemath.org/question/8278/can-octave-call-a-c-function/I have a notebook to solve a differential equation using gsl's rkf45 algorithm. Now I realize that the equation is too stiff and rkf45 is may not be the right algorithm to use. The function I am trying to solve is written in C syntax. I want to try using octave's lsode to solve the same equation since it has a option of solving "stiff" equation. I don't know the jacobian of the equation so I can't use the stiff options in gsl. The problem is that my function is very complicated it took me a long time to type it out. So my question is - is it possible to solve a differential equation in octave where the rhs is written in C syntax.ShashankThu, 18 Aug 2011 18:23:49 +0200https://ask.sagemath.org/question/8278/Sage Virtual Machine sudo password?https://ask.sagemath.org/question/8170/sage-virtual-machine-sudo-password/Hello, I´m a Linux newbie and I'm trying to install octave in the sage virtualbox virtual machine with the following command:
sudo aptitude install octave3.2
but I need to enter a password and I don´t know the password, can someone help? jamlatinoSat, 18 Jun 2011 20:36:35 +0200https://ask.sagemath.org/question/8170/Using octave in windowshttps://ask.sagemath.org/question/8164/using-octave-in-windows/I´m using sage via VirtualBox virtual machine from windows 7. I searched how to use octave but all I find refers to linux. Help will be appreciated.jamlatinoWed, 15 Jun 2011 16:54:52 +0200https://ask.sagemath.org/question/8164/Sage Notebook: how to set the path for Octave?https://ask.sagemath.org/question/7802/sage-notebook-how-to-set-the-path-for-octave/I'm using VMware to run Sage on my computer. Despite I have Octave installed, I don't know how to run any Octave command from the Notebook. When I select octave and try to execute any command (for instance, 1+1), I get the message "RuntimeError: Unable to start octave".
I've read on the help that I should have Octave available in the path... but I have no clue how to do that. Any help, please?FranThu, 09 Dec 2010 13:54:55 +0100https://ask.sagemath.org/question/7802/