使用Python运行Matlab会出现“没有名为matlab.engine的模块"错误 [英] Running Matlab using Python gives 'No module named matlab.engine' error

查看:1849
本文介绍了使用Python运行Matlab会出现“没有名为matlab.engine的模块"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Python运行Matlab代码.我试图遵循此

I am trying to run Matlab code using Python. I tried to follow the instructions given on this Mathworks page.

当尝试通过Python导入Matlab时,已使用pip install matlab安装了它.

When trying to import Matlab though Python, it was installed using pip install matlab.

但是,导入matlab.engine会给出错误No module named 'matlab.engine'; 'matlab' is not a package.也不能使用pip install engine进行安装.

However, importing matlab.engine gives the error No module named 'matlab.engine'; 'matlab' is not a package. It cannot be installed using pip install engine either.

如何使代码运行?我正在运行的Python代码如下:

How can I get the code running? The Python code I'm running is as below:

import matlab.engine
eng = matlab.engine.start_matlab()
eng.triarea(nargout=0)

Python版本-3.5

Python version - 3.5

Matlab版本-8.5.0.197613(R2015a)

Matlab version - 8.5.0.197613 (R2015a)

推荐答案

您需要安装适用于Python的Matlab引擎,并且无法使用pip进行安装.请尝试在此处中列出的说明>.我在下面简要列出了说明:

You need to install the Matlab Engine for Python, and it cannot be installed using pip. Try the instructions listed here. I have listed the instructions briefly below:

  1. 确保PATH中包含Python.
  2. 找到Matlab根文件夹.您可以在Matlab中使用matlabroot命令 来找到它.
  3. 在命令行中转到Matlab根文件夹.
  4. cd "matlabroot\extern\engines\python"(在Windows中)
  5. python setup.py install
  1. Make sure you have Python in your PATH.
  2. Find the Matlab root folder. You can use the matlabroot command within Matlab to find it.
  3. Go to the Matlab root folder in the command line.
  4. cd "matlabroot\extern\engines\python" (In Windows)
  5. python setup.py install

这篇关于使用Python运行Matlab会出现“没有名为matlab.engine的模块"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆