Python Error: ModuleNotFoundError: No module named 'numpy'

조회 수: 27 (최근 30일)
Michalis Konstantinou
Michalis Konstantinou 2021년 1월 20일
답변: surya venu 2024년 4월 2일
I am trying to import some python code, but I get the following error.
>> pyversion
version: '3.6'
executable: 'C:\Users\LMKO\AppData\Local\Programs\Python\Python36\python.exe'
library: 'C:\Users\LMKO\AppData\Local\Programs\Python\Python36\python36.dll'
home: 'C:\Users\LMKO\AppData\Local\Programs\Python\Python36'
isloaded: 1
>> py.importlib.import_module('Python_my_functions_v0_1')
Error using Python_my_functions_v0_1><module> (line 1)
Python Error: ModuleNotFoundError: No module named 'numpy'
Error in <frozen importlib>_call_with_frames_removed (line 205)
Error in <frozen importlib>exec_module (line 678)
Error in <frozen importlib>_load_unlocked (line 655)
Error in <frozen importlib>_find_and_load_unlocked (line 950)
Error in <frozen importlib>_find_and_load (line 961)
Error in <frozen importlib>_gcd_import (line 978)
Error in __init__>import_module (line 126)
>> py.importlib.import_module('numpy')
Error using <frozen importlib>_find_and_load_unlocked (line 948)
Python Error: ModuleNotFoundError: No module named 'numpy'
Error in <frozen importlib>_find_and_load (line 961)
Error in <frozen importlib>_gcd_import (line 978)
Error in __init__>import_module (line 126)
  댓글 수: 3
Eric Delgado
Eric Delgado 2021년 2월 22일
@Michalis Konstantinou, I figure out what happened with my issue... I had two instances of Python installed on my computer. So Matlab was pointing to the raw version of Python (without Numpy and others modules).
So I just configure the right version of Python and it's allright now. :)
pyenv('Version', 'C:\ProgramData\Anaconda3\python.exe')
I don't know if it's the same issue that you have, but you could try this solution. And obviously confirm that you do have installed Numpy module.
Michalis Konstantinou
Michalis Konstantinou 2021년 2월 23일
Hi @Eric Delgado, sorry for not answering sooner!
It was the same situation with mine, I had a raw version and a version from anaconda that included everything.
pyenv worked for me as well :)

댓글을 달려면 로그인하십시오.

답변 (1개)

surya venu
surya venu 2024년 4월 2일
Hi,
Here is a thing that you need to verify:
Check whether you have intalled "numpy", if not, you can install it viaa the following command:
> python -m pip install numpy
All the python dependencies needs to be installed seperately via "pip".
Additionally, make sure to setup the right python version before using it in MATLAB with "pyenv" command.
Hope it helps.

카테고리

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