Issue
I am brand new to Python and am following the tutorial at this link: https://code.visualstudio.com/docs/python/python-tutorial
I was able to execute
python -m pip install matplotlib
However, then when trying to run script:
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 20, 100)
plt.plot(x, np.sin(x))
plt.show()
I get:
PS C:\Code\Astros\Prism> & C:/Users/USER/AppData/Local/Programs/Python/Python38/python.exe c:/Code/Astros/Prism/Prism.py
Traceback (most recent call last):
File "c:/Code/Astros/Prism/Prism.py", line 1, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
PS C:\Code\Astros\Prism>
Any guidance would be much appreciated.
Solution
Can you check where the matplotlib
package has been installed through this command?
pip show matplotlib
And you are using the global Python on your computer:
C:/Users/USER/AppData/Local/Programs/Python/Python38/python.exe
It should be different.
You can switch to the python interpreter which you have installed the packages you want to import. Or install the packages in the interpreter you are using.
Answered By - Steven-MSFT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.