Questions tagged [oct2py]

Oct2Py is a Python library that allows the user to seamlessly call M-files and Octave functions from Python.

Oct2Py is a Python library which allows for seamless integration between Python and Octave. It manages the Octave session for you and transfers data between Python and the Octave session using MAT files.

Additionally, it provides OctageMagic which allows for integration of Oct2Py into Jupyter notebooks.

Example

from oct2py import Oct2Py

# Create an Octave session
oc = Oct2Py()

# Call an Octave function
x = oc.zeros(3, 3)

print(x, x.dtype)

#   [[ 0.  0.  0.]
#    [ 0.  0.  0.]
#    [ 0.  0.  0.]] float64

References

56 questions
11
votes
1 answer

Oct2Py only returning the first output argument

I'm using Oct2Py in order to use some M-files in my Python code. Let's say that I have this simple Matlab function : function [a, b] = toto(c); a = c; b = c + 1; end What happens if I call it in Octave is obviously : >> [x,y] = toto(3) x…
Telergoel
  • 353
  • 1
  • 13
8
votes
5 answers

oct2py isn't seeing OCTAVE_EXECUTABLE environment variable (Windows)

So, I'm trying to use oct2py on Windows, like so: from oct2py import octave That's literally the only code I need to reproduce the error. When I execute this, I get OSError: Octave Executable not found, please add to path or set"OCTAVE_EXECUTABLE"…
John Chrysostom
  • 3,973
  • 1
  • 34
  • 50
5
votes
1 answer

How do I add Octave to my PATH to use oct2py?

Final edit: adding export PATH=/usr/local/octave/3.8.0/bin:$PATH to my path was indeed sufficient to enable oct2py to work properly (so long as I restarted my terminal after the change). Huzzah! ---- Original post ---- I have successfully pip…
djsensei
  • 193
  • 1
  • 2
  • 9
5
votes
1 answer

How to install oct2py on windows?

I want to install oct2py in python. I am using windows 8.1 I used the command easy_install oct2py and I installed octave with the standard exe file. Now according to the installation guide I should add the octave path. setx PATH…
Donbeo
  • 17,067
  • 37
  • 114
  • 188
4
votes
2 answers

Difficulty using oct2py

I recently installed oct2py along with its dependencies in order to import a few matlab functions to be used in my python code. The .m file is located in the same directory as my python code. Could you please help me figure out, how I would import…
MShakeG
  • 391
  • 7
  • 45
4
votes
1 answer

oct2py - Calling an octave function using threads in python

I was trying to call an Octave function from a python program using two threads. My octave code is just to see how it works - testOctave.m function y = testOctave(i) y = i; end And the python program just tries to call it from oct2py import…
Avisek
  • 363
  • 1
  • 3
  • 16
3
votes
2 answers

sentinel error occurred while executing oct2py in python for running octave script

I am trying to use oct2py to run octave script(.m file) in python. here is the code import os os.environ['OCTAVE_EXECUTABLE'] = ('C:\\Program Files\\GNU Octave\\Octave-6.2.0\\mingw64\\bin\\octave-cli.exe') import oct2py out =…
3
votes
1 answer

Pip Package not available in conda

I'm creating a conda environment from a requirements file and it keeps throwing errors trying to find oct2py. I've used conda search oct2py which returns no result, but when I try pip search oct2py I can see that the correct version of oct2py…
3
votes
1 answer

ipython octavemagic

I'm on ubuntu with python 2.7 according to the documentation I should be able to get octave running from ipython: %install_ext octavemagic %load_ext octavemagic ('The file must have a .py or .zip extension', u'octavemagic') If I try: %install_ext…
darKoram
  • 1,113
  • 1
  • 14
  • 25
2
votes
0 answers

Problems importing the oct2py python package

I have installed the oct2py package using the pip command pip install oct2py, set the environement path of python, pip and octave as in the following picture: However, whenever I try to import it in my python script, I get the following error: I…
Wallflower
  • 550
  • 1
  • 4
  • 13
2
votes
1 answer

Oct2Py plot function not responding, can't change toolkit either

Using Linux. I'm able to use the plot3 octave function without the figure freezing through the command line if I use the gnuplot toolkit. However, when running it from python, using the oct2py module, I can't seem to change the toolkit although it…
Vasco
  • 21
  • 1
2
votes
1 answer

pyinstaller generated executable error with oct2py import

I am trying to make a python executable which uses oct2py to eval a .m file. The python script works just fine independently. I have been successful in using pyinstaller to make an executable (using --onefile, no errors in building it), but when I…
DNR
  • 31
  • 4
2
votes
1 answer

How to call octave function from python?

I have a problem.m file that has a function like this: myfun(p,m). It does some calculation and returns the result. For testing the execution of this function I have a test.m file that looks like this. myfun(myarg1,myarg2) If I run this file as: …
STZ
  • 161
  • 2
  • 10
2
votes
1 answer

Close Octave-cli instances while using Oct2Py in loop

So I'm running into an increasingly annoying problem while using Oct2Py in my python code to run a few Matlab codes. Every time I run Oct2py in my script it opens in my processes an octave-cli.exe *32 for each one but does not close it after the…
Telesto
  • 67
  • 1
  • 3
2
votes
1 answer

oct2py in Anaconda/Spyder not recognizing octave

Windows7 Anaconda/python ver 3.4 Octave ver 4.0.3 OCTAVE_EXECUTABLE = C:\Users\Heather\Octave-4.0.3\bin Hi all, I've been working a few days on trying to get oct2py working in Anaconda using Spyder. I was wondering if anyone could tell me the…
Telesto
  • 67
  • 1
  • 3
1
2 3 4