I installed matplotlib in my terminal on windows but whenever i run the code below, it says "ModuleNotFoundError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package" but I already installed matplotlib. this is the code i want to run:
import matplotlib.pyplot as plt
x = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
y =[100,92,53,54,12,547,4,88,11,15,689,7]
plt.plot(x, y)
plt.show()
this is the output it gives:
PS C:\Users\danie\OneDrive\Desktop\Junior year\second semester\programming 2> & C:/Users/danie/AppData/Local/Programs/Python/Python311/python.exe "c:/Users/danie/OneDrive/Desktop/Junior year/second semester/programming 2/matplotlib.py"
Traceback (most recent call last):
File "c:\Users\danie\OneDrive\Desktop\Junior year\second semester\programming 2\matplotlib.py", line 1, in <module>
import matplotlib.pyplot as plt
File "c:\Users\danie\OneDrive\Desktop\Junior year\second semester\programming 2\matplotlib.py", line 1, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package
someone help me please. Here is an image of my code and my error code.
i have two versions of python : 311 and 310, i uninstalled both and redownloaded 311 but it messed up my 'pip' so i went to the recycle bin to undo the delete now my 'pip' works but 'matplotlib' still doesn't work. i use both VScode and IDLE and they both do not work when running this code.
matplotlib.pyin the same folder which Python is seeing first instead of the actual package. So, make sure there's no files or folders with that name in the same directory as your script.matplotlib.pycor__pycache__folders that may have been created in the same directory as your script. Let me know if it did work