pyenv Python Interpreter error after change from OutOfProcess to InProcess

7 views (last 30 days)
I'm trying to import a python module within my MATLAB script
pyModule = py.importlib.import_module('MyModule');
This is working perfectly if I us my pyenv in Execution Mode OutOfProcess
pyenv('ExecutionMode','OutOfProcess')
ans =
PythonEnvironment with properties:
Version: "3.7"
Executable: "C:\Users\XXX\AppData\Local\Continuum\anaconda3\python.exe"
Library: "C:\Users\XXX\AppData\Local\Continuum\anaconda3\python37.dll"
Home: "C:\Users\XXX\AppData\Local\Continuum\anaconda3"
Status: NotLoaded
ExecutionMode: OutOfProcess
Yet, if I change the Exection Mode to InProcess
pyenv('ExecutionMode','InProcess')
ans =
PythonEnvironment with properties:
Version: "3.7"
Executable: "C:\Users\XXX\AppData\Local\Continuum\anaconda3\python.exe"
Library: "C:\Users\XXX\AppData\Local\Continuum\anaconda3\python37.dll"
Home: "C:\Users\XXX\AppData\Local\Continuum\anaconda3"
Status: NotLoaded
ExecutionMode: InProcess
it causes following error
Error using h5>init h5py.h5 (line 1)
Python Error: ImportError: DLL load failed: Die angegebene Prozedur wurde nicht gefunden.
Error in version><module> (line 15)
Error in __init__><module> (line 33)
Error in utils><module> (line 20)
Error in celebA_dataset><module> (line 8)
Error in __init__><module> (line 4)
Error in __init__><module> (line 14)
Error in __init__><module> (line 37)
Error in TD3_Agent><module> (line 19)
Error in <frozen importlib>_call_with_frames_removed (line 219)
Error in <frozen importlib>exec_module (line 728)
Error in <frozen importlib>_load_unlocked (line 677)
Error in <frozen importlib>_find_and_load_unlocked (line 967)
Error in <frozen importlib>_find_and_load (line 983)
Error in <frozen importlib>_gcd_import (line 1006)
Error in __init__>import_module (line 127)
This error occures independently of the interpreter used (anaconda / secondary installation / virtual environment).
I'm using the following libraries (supposedly essential for this problem):
  • tensorflow==2.6.0
  • h5py==3.1.0
but I have also already tried to downgrade to
  • tensorflow==2.2.0
  • h5py==2.1.0
without any success.
Is anybody else been running into a simmilar problem?

Answers (1)

surya venu
surya venu on 3 Apr 2024
Hello,
The interface between MATLAB and Python has encountered difficulties with multiprocessing. When attempting to use libraries that leverage multiprocessing capabilities, MATLAB may throw errors. Seems the Tensorflow and h5py libraries uses multiprocessing underhood.
To address this issue, consider upgrading to MATLAB R2024a, as the multiprocessing concerns have been resolved in this version.
I hope this information is beneficial.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!