Python Error: ModuleNotFoundError: No module named 'numpy'

108 visualizaciones (últimos 30 días)
Michalis Konstantinou
Michalis Konstantinou el 20 de En. de 2021
Respondida: surya venu el 2 de Abr. de 2024
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 comentarios
Eric Delgado
Eric Delgado el 22 de Feb. de 2021
@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 el 23 de Feb. de 2021
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 :)

Iniciar sesión para comentar.

Respuestas (1)

surya venu
surya venu el 2 de Abr. de 2024
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.

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