Error when calling Python ecCodes module from Matlab

조회 수: 5 (최근 30일)
Oscar Bondo
Oscar Bondo 2022년 4월 25일
답변: Pratyush Swain 2023년 11월 19일
I am trying to run a Python function from Matlab, but I get an error due to a missing library (the ecCodes library).
I tried to check the missing library by simply importing the module using:
>> py.importlib.import_module('eccodes')
Error using bindings><module> (line 35)
Python Error: RuntimeError: Cannot find the ecCodes library
However, I am perfectly able to import the module directly in Python through the Spyder IDE.
Furthermore, the ecCodes module should be in the Matlab search path, as it is located in:
C:\Users\username\AppData\Local\Continuum\anaconda3\Lib\site-packages\eccodes
Calling
>> py.sys.path
in Matlab shows that the parent-folder is in fact included:
C:\Users\username\AppData\Local\Continuum\anaconda3\Lib\site-packages
Has anyone faced similar issues when calling Python in Matlab?
Thank you in advance!
  댓글 수: 1
Madison Hetlage
Madison Hetlage 2023년 8월 8일
Hi, I am having this problem as well. Did you ever find a solution?

댓글을 달려면 로그인하십시오.

답변 (1개)

Pratyush Swain
Pratyush Swain 2023년 11월 19일
Hi Oscar Bondo,
I understand you are receiving an import error as MATLAB cannot find the python library named 'eccodes'. Please try the following workarounds for this issue:
1- Uninstall or delete the existing package library.
2- There is a conda package 'eccodes' for the C library, please make sure it is installed using the following command
conda install -c conda-forge eccodes
3- There is a pypi package 'eccodes' that contains only the Python bindings, please install using the following command.
pip install eccodes
Please try to install both, as the error message may be caused if you have the Python bindings, but not the underlying C library. Alternately, you may also install the package outside of your conda environment by compiling from source.
Hope this helps.

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by