Error 5001 when I use python multiprocessing module, which calls Matlab functions

I used python multiprocessing module for multiprocessing a image processs function, in which I started a Matlab engine and call Matlab functions. Then it appeared many pop-ups: Error 5001 - Unable to access services required to run MATLAB.
I tried to start the Matlab engine in main function and passed the engine as parameters to the image function, but then it appeared TypeError: cannot pickle 'weakref.ReferenceType' object.
The rough code is as follows:
def ImageProcess(data):
eng = matlab.engine.start_matlab()
...
return results
if __name__ == '__main__':
pool = multiprocessing.Pool()
results = pool.map(ImageProcess, data)
pool.close()
pool.join()

类别

帮助中心File Exchange 中查找有关 Call Python from MATLAB 的更多信息

提问:

2024-3-23

回答:

2024-3-28

Community Treasure Hunt

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

Start Hunting!

Translated by