As reported here, when you use Anaconda, install the packet using conda. In this case, the right instruction to use (on Ubuntu 18.04) is:

conda install -c conda-forge matplotlib

This will solve the problem.

If you use pip (you can), you will mess up all the dependencies (and for instance, the probability that other scripts/programs do not work anymore is not null: if you use Spyder, you will have big dependencies problem to face).

Optional:

In order to always avoid problem like this, I recommend you to use Virtual Enviroment:

Whats is it?

Geeksforgeeks explains it clearly.

How?

A step-by-step guide is always useful.

Answer from Leos313 on Stack Overflow
🌐
Anaconda.org
anaconda.org › conda-forge › matplotlib
matplotlib - conda-forge
Organization created on Apr 11, 2015 · A community-led collection of recipes, build infrastructure, and distributions for the conda package manager
🌐
Anaconda.org
anaconda.org › anaconda › matplotlib
matplotlib - anaconda | Anaconda.org
January 13, 2026 - anaconda/matplotlib · Community · Publication quality figures in Python · Overview · Files 869 · Labels 1 · Badges · Versions · 3.10.8 · To install this package, run one of the following: $conda install anaconda::matplotlib · Monthly · Downloads Updates ·
🌐
Professorkazarinoff
professorkazarinoff.github.io › Problem-Solving-101-with-Python › 05-Plotting-with-Matplotlib › 05.02-Installing Matplotlib
Installing Matplotlib - Problem Solving 101 with Python
> conda install matplotlib · Type y for yes when prompted. To install Matplotlib with pip (the Python package manager), open a terminal window and type: $ pip install matplotlib · This command installs Matplotlib in the current working python environment. Once installed, you can confirm ...
🌐
Problem Solving with Python
problemsolvingwithpython.com › 06-Plotting-with-Matplotlib › 06.02-Installing Matplotlib
Installing Matplotlib - Problem Solving with Python
Below are additional methods to ... can usually be seen in the Windows Start Menu. To install Matplotlib, open the Anaconda Prompt and type: > conda install matplotlib ·...
🌐
GeeksforGeeks
geeksforgeeks.org › techtips › how-to-install-matplotlib-on-anaconda
How to Install Matplotlib on Anaconda? - GeeksforGeeks
July 23, 2025 - Step 3: Create a new file by clicking on the New Dropdown Menu. Select the Python 3 option. Step 4: Paste the following command. And click on the Run button. Wait till the process gets completed. ... Hence, we have completed Matplotlib installation on conda.
🌐
Matplotlib
matplotlib.org › stable › install › index.html
Installation — Matplotlib 3.10.8 documentation
Mandatory dependencies should be ... pip or conda; therefore this list is primarily for reference and troubleshooting. ... See Get help. The first thing to try is a clean install and see if that helps. If not, the best way to test your install is by running a script, rather than working interactively from a python shell or an ...
Find elsewhere
🌐
Anaconda
anaconda.org › channels › conda-forge › packages › matplotlib › overview
matplotlib - conda-forge | Anaconda.org
conda-forge/matplotlib · Community · Publication quality figures in Python · Copied fromcf-post-staging / matplotlib · Overview · Files 3778 · Labels 10 · Badges · Versions · 3.10.8 · To install this package, run one of the following: $conda install conda-forge::matplotlib ·
Top answer
1 of 3
5

If you're using anaconda, your default environment is Python 2.7. You need to create a new environment and install matplotlib in there.

In a command prompt, do the following (saying yes to the questions):

conda create --name mpl33 python=3.3 matplotlib ipython-notebook
activate mpl33
ipython notebook

You should be able to import matplotlib when the notebook server comes up.

  • The first command simultaneously creates the environment and install the listed packages.
  • The second command activates the new environment by prepending its location to the system path
  • The third command just starts the ipython notebook so that you can test out everything

I don't know how pycharm works, but my guess is that you'll have to tell it to look for the right python that you want to use. In this case it'll be something like: C:/Users//anaconda/envs/mpl33. In any case, the command prompt should display the path when you activate the environment.

Once you've activated your environment, you can install more packages like this:

conda install pandas=0.12
conda install pyodbc statsmodels

You can specific version numbers of packages like the first command or simply accept the latest available version (default)

2 of 3
5

Assuming you've already installed a 3.x python env in anaconda, this one line should do the trick:
conda install matplotlib -n name
where name is the name you previously gave to your python 3 anaconda env. If you're not sure of the name you gave it, it will be the name of a subdir in the Anaconda\envs directory.

Background: I recently went through the same trouble with matplotlib not getting installed by default by anaconda when I added a full python 3 env, even though it's meant to. The above line solved it for me; it gave me the following warnings so it seems likely that the two different available versions caused it to initially install neither. However it allowed me to choose the one I wanted, and then everything worked great.

Warning: 2 possible package resolutions:
[u'dateutil-2.1-py33_2.tar.bz2', u'matplotlib-1.3.1-np18py33_1.tar.bz2', u'numpy-1.8.0-py33_0.tar.bz2', u'pyparsing-2.0.1-py33_0.tar.bz2', u'pyside-1.2.1-py33_0.tar.bz2', u'python-3.3.5-0.tar.bz2', u'pytz-2013b-py33_0.tar.bz2', u'six-1.6.1-py33_0.tar.bz2']
[u'dateutil-2.1-py33_2.tar.bz2', u'matplotlib-1.3.1-np17py33_1.tar.bz2', u'numpy-1.7.1-py33_3.tar.bz2', u'pyparsing-1.5.6-py33_0.tar.bz2', u'pyside-1.2.1-py33_0.tar.bz2', u'python-3.3.5-0.tar.bz2', u'pytz-2013b-py33_0.tar.bz2', u'six-1.6.1-py33_0.tar.bz2' ]

🌐
Matplotlib
matplotlib.org › 2.2.0 › users › installing.html
Installing — Matplotlib 2.2.0 documentation
# create a new environment with ... aware that pyqt doesn't mix well if # you have created the environment with conda-forge already activated...) conda install pyqt # this package is only available in the conda-forge channel conda install -c conda-forge msinttypes # for Python ...
🌐
Matplotlib
matplotlib.org › 3.1.1 › users › installing.html
Installing — Matplotlib 3.1.2 documentation
The binary requirements (png, FreeType,...) are statically linked and therefore not needed during the wheel install. Set up the conda environment. Note, if you want a qt backend, add pyqt to the list of conda packages. conda create -n "matplotlib_build" python=3.7 numpy python-dateutil pyparsing ...
🌐
Matplotlib
matplotlib.org › users › installing.html
Download matplotlib
Created using Sphinx 8.2.3 · Built from v3.10.8-7-g1957ba3918
🌐
Matplotlib
matplotlib.org › stable › users › installing › index.html
Installation — Matplotlib 3.8.4 documentation
May 28, 2023 - Mandatory dependencies should be ... pip or conda; therefore this list is primarily for reference and troubleshooting. ... See Get help. The first thing to try is a clean install and see if that helps. If not, the best way to test your install is by running a script, rather than working interactively from a python shell or an ...
🌐
GitHub
gist.github.com › nobuh › a4779f7d1cd788d17b753802dd431d1b
How to install matplotlib on MIniconda · GitHub
Save nobuh/a4779f7d1cd788d17b753802dd431d1b to your computer and use it in GitHub Desktop. Download ZIP · How to install matplotlib on MIniconda · Raw · install_matplotlib_on_miniconda.sh · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
🌐
Matplotlib
matplotlib.org › 3.2.2 › users › installing.html
Installing — Matplotlib 3.2.2 documentation
The binary requirements (png, FreeType,...) are statically linked and therefore not needed during the wheel install. Set up the conda environment. Note, if you want a qt backend, add pyqt to the list of conda packages. conda create -n "matplotlib_build" python=3.7 numpy python-dateutil pyparsing ...
🌐
Matplotlib
matplotlib.org › 3.5.0 › users › installing › index.html
Installation — Matplotlib 3.5.0 documentation
conda install -c conda-forge matplotlib · Matplotlib is part of major Python distributions: Anaconda · ActiveState ActivePython ·
🌐
GitHub
github.com › conda-forge › matplotlib-feedstock
GitHub - conda-forge/matplotlib-feedstock: A conda-smithy repository for matplotlib. · GitHub
matplotlib is a python 2D plotting ... can be used in Python scripts, the Python and IPython shell (ala MATLAB or Mathematica), web application servers, and six graphical user interface toolkits. ... Installing matplotlib-suite from the conda-forge channel can be achieved by adding ...
Starred by 22 users
Forked by 58 users
Languages   Batchfile 54.9% | Shell 45.1%
🌐
GeeksforGeeks
geeksforgeeks.org › installation guide › install-matplotlib-python
How to Install Matplotlib on python? - GeeksforGeeks
July 18, 2025 - Use these commands: conda create -n my-env conda activate my-env conda install matplotlib · conda config --env --add channels conda-forge conda install matplotlib · pip install matplotlib command can be used to install it.