To install Matplotlib, you can use pip
, which is the Python package installer. Below are the steps to install Matplotlib on your system.
Open a Command Line Interface:
Install Matplotlib:
pip install matplotlib
If you need a specific version of Matplotlib, you can specify it like thi
pip install matplotlib==3.4.3
Verify the Installation:
import matplotlib.pyplot as plt print(plt.__version__)
Using a virtual environment is a good practice to manage dependencies for different projects. Here’s how you can set up a virtual environment and install Matplotlib within it:
Create a Virtual Environment:
python -m venv myenv
myenv
with your preferred name for the virtual environment.Activate the Virtual Environment:
myenv\Scripts\activate
For macOS and Linux:
source myenv/bin/activate
Install Matplotlib in the Virtual Environment:
pip install matplotlib
Deactivate the Virtual Environment (when you’re done working):
deactivate