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 Overflowpython - anaconda cannot import matplotlib.pyplot - Stack Overflow
python - How do I install Matplotlib 3.4.1 in Anaconda? - Stack Overflow
How install matplotlib using Anaconda Navigator
Conda Not installing Matplotlib for PyPlot
Videos
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.
I had the same issue for days, just solved it by adding "%matplotlib inline" on top of "import matplotlib.pyplot as plt"
So enter this to import mathplotlib.pylot:
%matplotlib inline
import matplotlib.pyplot as plt
I went to the Matplotlib official site discourse and found this post: https://discourse.matplotlib.org/t/matplotlib-announce-ann-matplotlib-3-4-1/21991
Using pip install matplotlib==3.4.1 worked! Originally I had tried pip install matplotlib=3.4.1 but using only a single "=" is wrong.
I tried with DavidD003 solution
https://stackoverflow.com/a/66932922/11753330
and it worked also with conda command:
conda install -c conda-forge matplotlib==3.4.2
In this way the update succeded. Before:
matplotlib 3.3.4 py38hecd8cb5_0
matplotlib-base 3.3.4 py38h8b3ea08_0
After:
matplotlib 3.4.2 py38h50d1736_0 conda-forge
matplotlib-base 3.4.2 py38h6152e83_0 conda-forge
I've created a virtual environment named test_env I have been trying to add matplotlib using Anaconda Navigator this way
Then, it installs something. After installation finishes, it is like before installation again. I know, it is weird. But why it happens?
Also when I go to Anaconda Prompt and write these
activate test_env
conda install matplotlib
I see this error
ERROR conda.core.link:_execute(700): An error occurred while installing package 'defaults::qt-5.9.7-vc14h73c81de_0'. Rolling back transaction: done LinkError: post-link script failed for package defaults::qt-5.9.7-vc14h73c81de_0 location of failed script: C:\Users\mustafa\anaconda3\envs\test_env\Scripts\.qt- post-link.bat ==> script messages <== <None> ==> script output <== stdout: 1 file(s) copied. stderr: 'chcp' is not recognized as an internal or external command, operable program or batch file. 'chcp' is not recognized as an internal or external command, operable program or batch file. 'chcp' is not recognized as an internal or external command, operable program or batch file. return code: 1 ()
» pip install matplotlib