Matlab Linux Python: Numba causes Python Process to terminate unexpectedly

13 次查看(过去 30 天)
I am trying to import the python module "numba" (0.51.2) in Matlab 2020b (update 3 installed) running on Ubuntu 18.04 (Linux).
I set-up anaconda with basic modules installed (running Python 3.8.5)
pyenv('Version','/home/myusername/anaconda3/bin/python', "ExecutionMode","OutOfProcess")
I can then import a module such as numpy as follows:
py.importlib.import_module('numpy');
This works without any problems.
But when I try to import numba as follows, I get an error:
py.importlib.import_module('numba');
Error using py.importlib.import_module
Python process terminated unexpectedly. To restart the Python interpreter,
first call "terminate(pyenv)" and then call a Python function.
I checked my Python Environment Properties before trying to import numba:
PythonEnvironment with properties:
Version: "3.8"
Executable: "/home/myusername/anaconda3/bin/python"
Library: "/home/myusername/anaconda3/lib/libpython3.8.so"
Home: "/home/myusername/anaconda3"
Status: Loaded
ExecutionMode: OutOfProcess
ProcessID: "15165"
ProcessName: "MATLABPyHost"
Side note: All python modules are up to date. Numba is joinlty installed with llvmlite 0.32.1
MATLAB Version: 9.9.0.1538559 (R2020b) Update 3
Operating System: Linux 5.4.0-53-generic #59~18.04.1-Ubuntu SMP Wed Oct 21 12:14:56 UTC 2020 x86_64
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode

回答(1 个)

Rushikesh
Rushikesh 2024-10-9
I understand that you are experiencing a "Python process terminated unexpectedly" error, which I couldn't reproduce on my system using MATLAB R2020b and Conda Python 3.8. In your case, this issue is most likely due to library dependency conflicts within your Conda environment.
Following steps will help you to resolve the issue.
1. Create a New Conda Environment: To avoid duplicate dependency errors, try installing your libraries in a fresh Conda environment. This can help isolate any conflicts in library dependencies that might be causing the issue.
2. Check the 'numba' Library: It's possible that the specific version of the numba library you're using has compatibility issues. Consider trying a different version of numba to see if that resolves the problem.

类别

Help CenterFile Exchange 中查找有关 Call Python from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by