ModuleNotFoundError; running python script in matlab script

14 Ansichten (letzte 30 Tage)
Alessandro Maria Laspina
Alessandro Maria Laspina am 8 Mär. 2021
Beantwortet: Grace Kepler am 5 Mär. 2024
I have a python script that I want to run through MATLAB. I have installed python 3.9.2 for windows but when I run the following code:
system('python script_name.py');
I get the following error:
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
EDIT: Restarting matlab made it work. However, i get this error now:
import numpy as n;
ModuleNotFoundError: No module named 'numpy'
This refers to the library numpy I assume.

Antworten (2)

Rashed Mohammed
Rashed Mohammed am 11 Mär. 2021
Hi Maria
It seems that numpy module is not installed on your computer. You can install the python modules using the python package manager pip. Run "pip install <module_name>" to install the python module.
Hope this helps

Grace Kepler
Grace Kepler am 5 Mär. 2024
Since R2021b you can also run your Python file in MATLAB using "pyrunfile". This also allows you to return data to MATLAB.

Kategorien

Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by