Python Error: ModuleNotFoundError: No module named 'numpy'
108 次查看(过去 30 天)
显示 更早的评论
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
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.
回答(1 个)
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.
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!