Friday, August 26, 2022

How to install/update Matplotlib library ?

How to install Matplotlib library?

There are several ways how to install the latest version of the matplotlib library. However, we will cover only the basics i.e. to install or update the matplotlib library using pip or conda. To install the latest version of the matplotlib library using pip open the Command Prompt and type in the following command
pip install matplotlib
Of course, you have to have an internet connection so that the library can be downloaded, extracted, and installed. On Linux operating system open Terminal and type in the following
pip install matplotlib
To install it using conda open Command Prompt or Terminal and type in the following code.
conda install -c conda-forge matplotlib
After installation is complete, you can check if matplotlib was successfully installed. To do that open Command Prompt, Terminal, Spyder,... and type in the following
import matplotlib
matplotlib.__version__
Output:
'3.4.3'
This is our current version of the matplotlib library. Of course, the version of your Matplotlib library could differ.

How to update Matplotlib library?

If you want to upgrade to the latest version of Matplotlib library using pip then open the Command Prompt or Terminal and type in the following
pip install --upgrade matplotlib
The command will start searching for the latest version of the matplotlib library and if the newer version is found it will be installed as shown below.
Requirement already satisfied: matplotlib in c:\anaconda3\lib\site-packages (3.4.3)
Collecting matplotlib
Downloading matplotlib-3.5.3-cp39-cp39-win_amd64.whl (7.2 MB)
|████████████████████████████████| 7.2 MB 80 kB/s
Requirement already satisfied: python-dateutil>=2.7 in c:\anaconda3\lib\site-packages (from matplotlib) (2.8.2)
Requirement already satisfied: pillow>=6.2.0 in c:\anaconda3\lib\site-packages (from matplotlib) (8.4.0)
Requirement already satisfied: cycler>=0.10 in c:\anaconda3\lib\site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: pyparsing>=2.2.1 in c:\anaconda3\lib\site-packages (from matplotlib) (3.0.4)
Requirement already satisfied: numpy>=1.17 in c:\anaconda3\lib\site-packages (from matplotlib) (1.20.3)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\anaconda3\lib\site-packages (from matplotlib) (1.3.1)
Requirement already satisfied: fonttools>=4.22.0 in c:\anaconda3\lib\site-packages (from matplotlib) (4.25.0)
Requirement already satisfied: packaging>=20.0 in c:\anaconda3\lib\site-packages (from matplotlib) (21.0)
Requirement already satisfied: six in c:\anaconda3\lib\site-packages (from cycler>=0.10->matplotlib) (1.16.0)
Installing collected packages: matplotlib
Attempting uninstall: matplotlib
Found existing installation: matplotlib 3.4.3
Uninstalling matplotlib-3.4.3:
Successfully uninstalled matplotlib-3.4.3
Successfully installed matplotlib-3.5.3
To verify if the newer version of matplotlib is installed run Python (CMD/Termina /Spyder - described previously) and type in the following.
import matplotlib
matplotlib.__version__
Output:
'3.5.3'
If you want to upgrade to the latest version of the matplotlib library using conda then open the Command Prompt/Terminal /Anaconda Prompt and type in the following
conda install -c conda-forge matplotlib
The command will start searching for a newer version of matplotlib. If you have the latest version of the matplotlib then it will write the following output.
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
Retrieving notices: ...working... done
It should be noted that if the conda command is run without the writing permission privileges (Administrator mode) that the following output will be shown.
EnvironmentNotWritableError: The current user does not have write permissions to the target environment.
environment location: C:\Anaconda3

No comments:

Post a Comment