Reputation: 483
I've been attempting to install Matplotlib for a graphing project in Python. In accordance with recommendation from the Matplotlib website, I installed Anaconda as a pre-packaged python distributor. Anaconda seems to have installed correctly. To install matplotlib, I typed in the command line:
pip install matplotlib
Which brings up multiple messages stating: "Requirement already satisfied." When in my python script I typed:
import matplotlib.pyplot as plt
I received an error message stating:
ImportError: No module named matplotlib.pyplot
I'm using an old Windows XP operating system.
I've looked everywhere for help, and have tried installing matplotlib numerous times via the command line! Any help would be greatly appreciated... Thank you!!
Upvotes: 2
Views: 20475
Reputation: 2163
Make sure your version of pip corresponds to your version of python. One way to do this is the following:
python -m pip install matplotlib
The -m for module means that it will look in the site-packages for that python for the pip module.
You can also do:
>>> import sys
>>> print("\n".join(sys.path))
to list the path as understood by python, then check whether matplotlib is indeed on one of the listed paths (usually site-packages).
To find the locations of pip and python use the following on the Windows console:
where python
where pip
From the path you should be able to determine whether pip and python are from the same package. If not, uninstall one of the python installations, or at least remove it from the PATH variable.
Upvotes: 2