oct2py 没有看到 OCTAVE_EXECUTABLE 环境变量(Windows) [英] oct2py isn't seeing OCTAVE_EXECUTABLE environment variable (Windows)
问题描述
所以,我尝试在 Windows 上使用 oct2py,如下所示:
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.
当我执行这个时,我得到OSError: Octave Executable not found,请添加到路径或设置OCTAVE_EXECUTABLE"环境变量
.但是,我已经将 OCTAVE_EXECUTABLE
设置为系统变量,它指向 "C:\Octave\Octave-4.4.1\bin\octave-cli-4.4.1.exe"
.打开命令行并运行 %OCTAVE_EXECUTABLE%
给了我 Octave CLI,所以我知道它是对的.
When I execute this, I get OSError: Octave Executable not found, please add to path or set"OCTAVE_EXECUTABLE" environment variable
. However, I have already set OCTAVE_EXECUTABLE
as a system variable, which points to "C:\Octave\Octave-4.4.1\bin\octave-cli-4.4.1.exe"
. Opening up the command line and running %OCTAVE_EXECUTABLE%
gives me the Octave CLI, so I know it's right.
我试过重新启动.我还尝试将 Octave 文件夹添加到我的路径并删除 OCTAVE_EXECUTABLE
.都不行.
I've tried rebooting. I've also tried adding the Octave folder to my Path and removing OCTAVE_EXECUTABLE
. Neither work.
我也试过只使用 octave-cli.exe
,我试过做 print(os.environ['OCTAVE_EXECUTABLE'])
,返回预期路径.
I've also tried using just octave-cli.exe
, and I've tried doing print(os.environ['OCTAVE_EXECUTABLE'])
, which returns the expected path.
这里有什么想法吗?
推荐答案
尽管您在评论中提到了:
In spite of what you mention in your comment:
似乎在某处,octave.exe 被octave-cli.exe 替换了.不再随 Octave 包分发 Octave.exe.其他人已成功将 OCTAVE_EXECUTABLE 指向 Octave-cli.exe
It appears that, somewhere along the line, octave.exe got replaced with octave-cli.exe. There is no longer an octave.exe distributed with the Octave package. Others have successfully pointed OCTAVE_EXECUTABLE at octave-cli.exe
最近有更多人遇到了类似的问题,几个小时前 oct2py
开发人员在 5.0.0
版本中修复了它.实际上他们说:
Recently more people had a similar issue and the oct2py
developers fixed it in the 5.0.0
version some hours ago. Actually they said:
啊,我明白问题出在哪里了.方便的 octave
实例在您有机会设置 executable
属性之前创建.鉴于这一事实,我认为唯一正确的答案是删除可执行参数以支持使用 PATH
或 OCTAVE_EXECUTABLE
环境变量.
Ah, I see what the issue is here. The convenience
octave
instance is created before you get a chance to set theexecutable
property. Given that fact, I think the only right answer is to remove the executable argument in favor of usingPATH
or theOCTAVE_EXECUTABLE
environment variable.
无论如何,我不得不调整我的代码以使其工作更新环境变量OCTAVE_EXECUTABLE
:
Anyway I had to adapt my code to make it work updating the environment variable OCTAVE_EXECUTABLE
:
import shutil
import os
import sys
if sys.platform == 'win32':
# os.environ['OCTAVE_EXECUTABLE'] = shutil.which('octave')
# >> I had to replace this with this other line >>
os.environ['OCTAVE_EXECUTABLE'] = shutil.which('octave-cli.exe')
这篇关于oct2py 没有看到 OCTAVE_EXECUTABLE 环境变量(Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!