简体   繁体   中英

Unable to run a octave function using oct2py through the web server

I am using oct2py to call a octave function in my python code. The file is saved as .py file in the htdocs folder.

#!/usr/bin/python
import cgi
import oct2py
from oct2py import octave
print('Content-type:text/html\r\n\r\n')
print('<!DOCTYPE html>')
firnum='23'
secnum='33'
octave.addpath('/Applications/XAMPP/xamppfiles/htdocs/mypython/Octavemfiles/')
firnum=int(firnum)
secnum=int(secnum)
answer=octave.mymultfunct(firnum,secnum)
print(answer)

The code works well when executing from the terminal and gives the answer. But when I call it through the web, the oct2py gives an error stating

OSError: Octave Executable not found, please add to path or set"OCTAVE_EXECUTABLE" environment. 

Please suggest a way out so I can call the function from octave. The octave function is just multiplying the numbers.

In Linux distribution: command : sudo pip install oct2py Error:

import oct2py Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/oct2py/ init .py", line 38, in octave = Oct2Py() File "/usr/local/lib/python2.7/dist-packages/oct2py/core.py", line 73, in init self.restart() File "/usr/local/lib/python2.7/dist-packages/oct2py/core.py", line 508, in restart logger=self.logger) File "/usr/local/lib/python2.7/dist-packages/octave_kernel/kernel.py", line 157, in init self.executable = self._get_executable() File "/usr/local/lib/python2.7/dist-packages/octave_kernel/kernel.py", line 432, in _get_executable raise OSError(msg) OSError: Octave Executable not found, please add to path or set"OCTAVE_EXECUTABLE" environment variable

Solution Please install octave using : command : sudo apt-get install octave

ubuntu@host:~$ python Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information.

import oct2py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM