Getting h5py error for python

I am trying to load h5py module in matlab and I am getting this error:
Error using h5>init h5py.h5 (line 1)
Python Error: ImportError: DLL load failed: The specified procedure could not be found.
I installed the versio 3.2.1 of this package through python but can not load it in matlab. Anyone can help in this?

답변 (1개)

Yongjian Feng
Yongjian Feng 2021년 8월 11일

0 개 추천

  1. Make sure you can use h5py in python first.
  2. Check where it is installed. Then use setenv inside matlab to set the env var PYTHONPATH to point to that location.

댓글 수: 4

AsukaIkeda
AsukaIkeda 2022년 2월 16일
편집: AsukaIkeda 2022년 2월 16일
I have the same problem.
When I run "py.help('h5py')" in matlab(R2021b_update2) , I got the following error.
problem in h5py - ImportError: DLL load failed: 指定されたモジュールが見つかりません。
(The meaning of the last Japanese word is "The specified module was not found.")
  1. I can use h5py in python script.
  2. I set "C:\Users\(my user name)\Anaconda3\envs\tf37\Lib\site-packages\h5py" to PYTHONPATH , and restart the computer. But I got the same error in matlab. *"tf37" is my environment name.
pyenv returns the following values:
Version: "3.7"
Executable: "C:\Users\(my user name)\Anaconda3\envs\tf37\python.exe"
Library: "C:\Users\(my user name)\Anaconda3\envs\tf37\python37.dll"
Home: "C:\Users\(my user name)\Anaconda3\envs\tf37"
Status: Loaded
ExecutionMode: InProcess
ProcessID: "12684"
ProcessName: "MATLAB"
I know that matlab is incompatible with Anaconda, but If anyone knows how to do this, please let me know. Thanks.
Yongjian Feng
Yongjian Feng 2022년 2월 16일
편집: Yongjian Feng 2022년 2월 16일
Inside matlab, check the PYTHONPATH env as well. It might not be the same as the one of the system.
In matlab command line, type
getenv('PYTHONPATH')
To add path, in matlab command line
setenv('PYTHONPATH', new_path)
AsukaIkeda
AsukaIkeda 2022년 2월 22일
@Yongjian Feng Thank you for the answer, and sorry I didn't notice your comment.
I tried your command inside matlab. But it still didn't work.
This is my matlab setup.
getenv('PYTHONPATH')
ans = 'C:\Users\(my user name)\anaconda3\envs\tf37\lib\site-packages\h5py'
However, I found the another solution.
I copied the following DLL files
from "C:\Users\(my user name)\anaconda3\envs\tf37\Library\bin"
to "C:\Users\(my user name)\anaconda3\envs\tf37\Lib\site-packages\h5py" .
cilkrts20.dll
concrt140.dll
hdf5.dll
hdf5_cpp.dll
hdf5_hl.dll
hdf5_hl_cpp.dll
hdf5_tools.dll
ifdlg100.dll
libchkp.dll
libicaf.dll
libifcoremd.dll
libifcorert.dll
libifportmd.dll
libirngmd.dll
libmmd.dll
libmpx.dll
msvcp140.dll
svml_dispmd.dll
szip.dll
vcruntime140.dll
zlib.dll
for numpy, I also made the following settings.
Yongjian Feng
Yongjian Feng 2022년 2월 22일
I see. Matlab can find the python package, but has trouble to find the dependent dll. Maybe you can set the PATH env var to point to those dll.

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

카테고리

도움말 센터File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

질문:

2021년 8월 9일

댓글:

2022년 2월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by