In this Python tutorial we will discuss various methods for installing matplotlib. There are atleast 4 ways we can install matplotlib in Python, listed below:
- Installation using pip
- Installing matplotlib in Linux
- Installing matplotlib using GitHub
- Installation on Conda
Installation using Pip
Use the following command to download the official version of matplotlib using the pip package manager.
pip install matplotlib
If you face any error, it’s likely due to the fact that you are not executing this command in the directory where the Python installation was done. You can learn more about this problem by checking out our getting started with Python Guide.
Installing matplotlib in Linux
Commands that you can use in the various Linux distributions to download matplotlib.
sudo apt-get install python3-matplotlib
sudo dnf install python3-matplotlib
sudo yum install python3-matplotlib
sudo pacman -S python-matplotlib
Installing matplotlib using GitHub
This method involves directly grabbing the files from the GitHub repo where matplotlib is developed. You will however, have to make sure you have the required dependencies.
Using this method will also give you access to the latest developers version of matplotlib.
Using the HTTPS link:
git clone https://github.com/matplotlib/matplotlib.git
or using SSH:
git clone firstname.lastname@example.org:matplotlib/matplotlib.git
To get new updates made to the GitHub repo, use the following command to pull the new changes.
Installation on Conda
Matplotlib install command for the Anaconda main channel.
conda install matplotlib
If you weren’t able to find an answer to your problem in this tutorial, or if you are facing some other issues regarding the installation of matplotlib, refer to the official matplotlib website.
This marks the end of the Installing Matplotlib in Python Tutorial. Any suggestions or contributions for CodersLegacy are more than welcome. Questions regarding the tutorial content can be asked in the comments section below.