【问题标题】:Run MATLAB executable form Python: Could not find the version 9.1 of matlab runtime从 Python 运行 MATLAB 可执行文件:找不到 9.1 版的 matlab 运行时
【发布时间】:2023-03-29 03:19:01
【问题描述】:

我有一个同事用 Python 2 编写的脚本。我做了一些更改以将其转换为 Python 3(不确定是否正确更正)。我已经用 Python 2 代码注释掉了部分。 问题是脚本运行但找不到 Matlab 运行时的版本。 我见过类似的问题,但答案不清楚。

这是我得到的:找不到 Matlab 运行时的 9.1 版。正在尝试加载 mclmcrrt9_1.dll...

def run_subprocess(process_name, arguments):
"""
:param process_name:
:type process_name: Pathlib2.Path()
:param arguments:
:type arguments: list
"""
# process_name = process_name.parent.joinpath(process_name.name + '.exe')     # Python 2
process_name = process_name.parent.joinpath(process_name.name)
command = [str(process_name)]
for item in arguments:
    command.append(item)

# sys.stderr.write(unicode(str(command) + u'\n').encode(cfg.encoding, 'replace'))   # Python 2
sys.stderr.write((str(command) + u'\n'))
output = ''
error = ''
try:
    my_process = psutil.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    print(my_process)
except Exception as e:
    # sys.stderr.write(unicode(str(e) + u'\n').encode(cfg.encoding, 'replace'))   # Python 2
    sys.stderr.write((str(e) + u'\n'))
    return '', 'Exception encountered with psutil.Popen(' + str(command) + ')'

try:
    output, error = my_process.communicate()
except Exception as e:
    sys.stderr.write(unicode(str(e) + u'\n').encode(cfg.encoding, 'replace'))
    return '', 'Exception encountered with psutil.Popen(' + str(command) + ')'
# sys.stdout.write(unicode(output + u'\n').encode(cfg.encoding, 'replace'))  # Python 2
sys.stdout.write(output)
# sys.stderr.write(unicode(error + u'\n').encode(cfg.encoding, 'replace'))   # Python 2
sys.stderr.write(output)
return output, error

【问题讨论】:

    标签: python windows matlab parameters executable


    【解决方案1】:

    您可以尝试使用pymatlab 包。

    Here 是一些如何使用它的示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-17
      相关资源
      最近更新 更多