'ModuleNotFoundError: No module named 'numpy.core._multiarray_umath' on matplotlib import
I'm trying to run a simple testfile on a remote Server. But it throws a numpy error for matplotlib.pyplot. Here is the code
import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
np.random.seed(19680801)
x, y = np.random.randn(2, 100)
print('x')
print(x)
print('y')
print(y)
fig, [ax1, ax2] = plt.subplots(2, 1, sharex=True)
ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2)
ax1.grid(True)
ax2.acorr(x, usevlines=True, normed=True, maxlags=50, lw=2)
ax2.grid(True)
plt.show()
Here is the error message.
PyTorch/1.7-py36-cuda11/numpy/core/overrides.py", line 7, in from numpy.core._multiarray_umath import ( ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "graph_test.py", line 1, in import matplotlib.pyplot as plt
/PyTorch/1.7-py36-cuda11/numpy/core/init.py", line 48, in raise ImportError(msg) ImportError: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed. We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
- The Python version is: Python3.7 from "/projects/smiles/Model/venv/bin/python"
- The NumPy version is: "1.19.4"
and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
Python Version: 3.7.5
Numpy Version: 1.19.4
Matplotlib version: 3.3.3
Solution 1:[1]
According to the site given by the library numpy:
to fix the error you need to check couple things that commonly gives this error:
1- Check if you are using the right version of python and the right version of numpy, check the documentation fo further information.(you might also have multiple versions of python that can affect the run of your libraries)+ try the newer version of numpy 1.19.5
2- check if your python path is in the environment variables of your system. you can check your path by running this command in your terminal:
import os
print("PYTHONPATH:", os.environ.get('PYTHONPATH'))
print("PATH:", os.environ.get('PATH'))
3- try to uninstall and reinstall the numpy library(make sure to install the right version to satisfy what ever program you want to run)
4- if any of the above solutions didn't work, I highly recomend to install the anaconda installer here is a link to it : https://www.anaconda.com/products/individual
and that because anaconda most likely solve the problems of downloading libraries/ errors you get from those libraries.
Hopefully those solutions helped you, and feel free to ask any question regarding it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Wesley Cheek |