How to run a python file .py in matlab

30 visualizaciones (últimos 30 días)
PA
PA el 29 de Sept. de 2023
Respondida: Avni Agrawal el 28 de En. de 2025 a las 8:51
I am using Anaconda and then i saved the python anaconda script file as .py file extension and when i call the python script file i get this error.
Error using <string>><module> (line 1) Python Error: ModuleNotFoundError: No module named 'skopt' . However i already have installed scikit-optimize in ana conda. I refer this too
Python Error: ModuleNotFoundError: No module named 'numpy' but i still have the issue
  1 comentario
Rik
Rik el 1 de Oct. de 2023
Can you post Matlab code and a minimal example that reproduces the error?

Iniciar sesión para comentar.

Respuestas (1)

Avni Agrawal
Avni Agrawal el 28 de En. de 2025 a las 8:51
Hi @PA,
I understand you are experiencing an error when attempting to execute a Python Anaconda script from within the MATLAB environment. This issue arises because MATLAB requires a supported version of the reference implementation, CPython, installed on your system to interact with Python modules. You can find more details about this requirement in the official MATLAB documentation https://www.mathworks.com/help/matlab/matlab_external/install-supported-python-implementation.html.
By default, MATLAB does not directly support executing Anaconda Python scripts. However, there are workarounds that allow you to run Conda scripts from MATLAB. These solutions typically involve modifying the MATLAB environment variables to integrate Anaconda's Python interpreter.
For detailed guidance on implementing these workarounds, I recommend checking out this MATLAB Central answer: https://www.mathworks.com/matlabcentral/answers/427187-problem-with-python-numpy?s_tid=mwa_osa_a.
I hope this helps!

Categorías

Más información sobre Call Python from MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by