In Visual Studio Code, I can use numpy library but not the matplotlib.pyplot library even though I have installed both
The example code in visual studio code:
mport matplotlib.pyplot as plt
import numpy as np
xpoints = np.array([0, 6])
ypoints = np.array([0, 250])
plt.plot(xpoints, ypoints)
plt.show()
I get in the terminal
ModuleNotFoundError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package
However, when I type pip3 show matplotlib, I get the message that it is alr installed:
Name: matplotlib
Version: 3.7.1
Summary: Python plotting package
Home-page: https://matplotlib.org
Author: John D. Hunter, Michael Droettboom
Author-email: [email protected]
License: PSF
Location: /home/huinker/.local/lib/python3.10/site-packages
However, VS code works with other library like numpy. Example code
import numpy
A, B=numpy.array(list(map(int, input().split()))), numpy.array(list(map(int, input().split())))
print (numpy.inner(A, B))
print (numpy.outer(A, B))
the code works with numpy library. when i try in the termial pip3 show numpy:
Name: numpy
Version: 1.24.3
Summary: Fundamental package for array computing in Python
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email:License: BSD-3-Clause
Location: /home/huinker/.local/lib/python3.10/site-packages
Requires:
Required-by: contourpy, matplotlib
What is my problem with the environment?

import sys; print(sys.executable)matplotlib.pyor have such file in the directory? Current directory gets prepended to path, so current files get searched before the installed ones