gpt4 book ai didi

python - 激活 MATLAB 后使用 MATLAB Engine for Python 时出现 EngineError : Transport stopped.

转载 作者:行者123 更新时间:2023-12-01 09:11:24 33 4
gpt4 key购买 nike

我按照 this 安装了 MATLAB Engine解决方案,它也启动了,但是通过执行它,出现以下错误:

Traceback (most recent call last):

File "<ipython-input-1-7f0848dd34ed>", line 1, in <module>
runfile('/media/geodasie/dat/Dennis/Python/PythonProgram/CryoSat2_main_Test.py', wdir='/media/geodasie/dat/Dennis/Python/PythonProgram')

File "/home/geodasie/anaconda3/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 705, in runfile
execfile(filename, namespace)

File "/home/geodasie/anaconda3/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "/media/geodasie/dat/Dennis/Python/PythonProgram/CryoSat2_main_Test.py", line 288, in <module>
eng = matlab.engine.start_matlab() # start Matlab

File "/home/geodasie/anaconda3/lib/python3.6/site-packages/matlab/engine/__init__.py", line 115, in start_matlab
eng = future.result()

File "/home/geodasie/anaconda3/lib/python3.6/site-packages/matlab/engine/futureresult.py", line 67, in result
return self.__future.result(timeout)

File "/home/geodasie/anaconda3/lib/python3.6/site-packages/matlab/engine/matlabfuture.py", line 87, in result
handle = pythonengine.getMATLAB(self._future)

EngineError: Transport stopped.

发生错误的代码序列是这样的:

Path_year = fileName[19:23] + '/'
Path_month = fileName[23:25] + '/'
# read DBL file with the help of the Matlab function provided by ESA
eng = matlab.engine.start_matlab() # start Matlab
DATA = eng.main_read(path_saveFilefromFTP + Path_year + Path_month + fileName) # run matlab script
eng.quit() # end Matlab

这段代码已经在另一台电脑上运行,但遗憾的是在这台电脑上出现了错误。

我多次安装了 MATLAB Engine,但结果都是一样。根据调用的 futureresult.py 函数,超时是返回结果之前等待的秒数。但默认情况下,该函数会等待,直到有结果为止。因为似乎发生了错误,所以该函数无法提供结果。 future 结果解释如下:

An instance of FutureResult is returned from each asynchronous invocation of a function call: start_matlab, connect_matlab, or MatlabEngine.. The future result serves as a placeholder of the actual result, so the future result can be returned immediately. The actual result is placed into the placeholder when the function finishes its evaluation.

但是程序已经通过调用引擎 MATLAB Engine 停止了,所以 MATLAB 和 Python 之间的连接应该有问题。

我在 Ubuntu 16.04 LTS 中使用 Python 3.6.5 和 Anaconda 5.2,并安装了 MATLAB 2018a。

更新:现在我在另一台电脑上测试它并出现相同的错误。似乎总是在我必须在这台电脑上激活 MATLAB 之后发生这种情况。因此我更改了标题。

有人知道如何解决这个问题吗?

提前致谢!

最佳答案

经过多次测试,唯一的解决方案是删除 MATLAB,然后重新安装。也许有更好的解决方案,但由于 MATLAB 需要激活并且已经激活,我猜测 MATLAB 许可证存在问题,因此 MATLAB 没有响应 MATLAB Engine。

关于python - 激活 MATLAB 后使用 MATLAB Engine for Python 时出现 EngineError : Transport stopped.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51626973/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com