Error when calling Python ecCodes module from Matlab

7 views (last 30 days)
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!

Answers (1)

Pratyush Swain
Pratyush Swain on 19 Nov 2023
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.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!