pyrunsfile doesn't work when python script includes "import"
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi.
I want to run a python script using pyrunfile.
I have confirmed that a very simple python script works through pyrunfile.
such as Ex.py :
% Ex.py
x = 1+1;
print(x);
However, if I add the code to import additionally installed libraries such as numpy, matplotlib, and tensorflow, the following error occurs.
Python Error: ModuleNotFoundError: No module named 'numpy'
I have obviously installed numpy, and when I run the python script through pycharm it works fine.
Like many advices before, I tried creating a virtual environment via anaconda prompt, installing numpy first and then running matlab, but the same problem persisted.
Am I missing something when I load the python environment to matlab?
I am using matlab 2021b, and python 3.7.9
Please help.
Thank you.
0 Kommentare
Antworten (1)
MJFcoNaN
am 3 Jul. 2022
Hello,
As I know, there were some python packages that some versions of matlab can't load if you installed them in virtual environment (such as from conda), and numpy was certainly one of them.
I am not sure how newer matlab deal with it, but I will suggest you try to avoid anaconda and only use the original python, pip, then make matlab load it.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!