Matplotlib.pyplot

I am using 3.9 Python and when I tried to import in my Python shell, the Matplotlib.pyplot kicked out an error. The error was the following:

import matplotlib.pyplot as plt
ModuleNotFoundError: No module named ‘matplotlib’

  1. I then went to my Windows power shell and once again installed “matplotlib.” The installation was successful. Thus, when I go to Python and try to import I get an error that the module does not recognize the name.

Any way you can direct me. I have been learning Python the past four weeks…

Gene

C:\Users\Gene>python -m pip install – matplotlib
Requirement already satisfied: matplotlib in c:\users\gene\appdata\local\programs\python\python39\lib\site-packages (3.5.1)
Requirement already satisfied: fonttools>=4.22.0 in c:\users\gene\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (4.28.5)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\gene\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (1.3.2)
Requirement already satisfied: packaging>=20.0 in c:\users\gene\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (21.3)
Requirement already satisfied: pyparsing>=2.2.1 in c:\users\gene\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (3.0.6)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\gene\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (2.8.2)
Requirement already satisfied: cycler>=0.10 in c:\users\gene\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (0.11.0)
Requirement already satisfied: pillow>=6.2.0 in c:\users\gene\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (8.4.0)
Requirement already satisfied: numpy>=1.17 in c:\users\gene\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (1.21.4)
Requirement already satisfied: six>=1.5 in c:\users\gene\appdata\local\programs\python\python39\lib\site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)

This is almost always because the python you are using in your “python shell” is different from the python you are calling pip with. To test, make a file test.py with import matplotlib.pyplot as plt, and run that from the power shell: python test.py.

You can also test by doing python --version in your windows powershell, and import sys; print(sys.version) in your python shell.

Hi;
I took your suggestions and I could not see any differences when I ran the mentioned tasks.

Gene

A. To test, make a file test.py with import matplotlib.pyplot as plt , and run that from the power shell: python test.py .

 === RESTART: C:\Users\Gene\AppData\Local\Programs\Python\Python39\test_A1.py ===

3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)

  1. Test by doing python --version (Windows Powershell) The results below.
    Results ===

PS C:\users\gene\appdata\Local\Programs\Python\Python39> python --version
Python 3.9.7
==================================================================strong text
1_A Import sys; print(sys.version) in my python shell
Results
=== RESTART: C:/Users/Gene/AppData/Local/Programs/Python/Python39/test_A2.py ===
3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)]