pyrunsfile doesn't work when python script includes "import"
조회 수: 22 (최근 30일)
이전 댓글 표시
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
답변 (1개)
MJFcoNaN
2022년 7월 3일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!