31 Years of Python | 48 Hour Sale Extension!!!
days
hours
minutes
seconds

What actually works to update matplotlib...? (Frustration level rising.)

Hello,

I am working on a project (a Dataquest guided project) and a heatmap that I am creating does not show properly. After some searching on the internet I figured out that to solve that I should update matplotlib from version 3.1.1 to version 3.1.2.

(I just figured out that also on Dataquest community, someone ran into the same even: this post.)

I am running everything ‘locally’ on a private laptop. Where I started off (some time ago) with the Anaconda distribution.

Now I hoped that such update would be straightforward. Unfortunately I already spent some 2 hours on this, to no avail :unamused:

What I tried so far, based on searching online.

  1. Try from a Jupyter notebook

From within a Jupyter notebook, run conda install matplotlib=3.1.2.
After half an hour or something, nothing seems to have changed.
The cell with the command did not complete. The cell in the notebook didn’t get a number, and there is still an hour-glass icon at the tab in my browser. And when checking my version it is still 3.1.1.

  1. Try from Anaconda Navigator

Then I tried to update via Anaconda navigator. When I try to update there, it seems stuck right after triggering the update as well. I watched this for a long time:

I do not know how to proceed best now. I found suggestions as well to try from the command line. (Without knowing whether that should then be Anaconda prompt or e.g. Ubuntu bash prompt.)

But I am seeking help here first before continuing trial-and-effort.

Does anyone know a way that should really work? And/or know why I am not having success?

Hi.

Close everything and start again.

Some ideas to be tried from the Anaconda terminal:

  • pip install --upgrade matplotlib
  • conda update --all

If still not working, why not give it a try to seaborn?

import seaborn as sns
sns.heatmap(data)

Best

W.

1 Like

Thank you @WilfriedF !

pip install --upgrade matplotlib did the trick for me. That finished within seconds. It obviously did not update to 3.1.2 but to a more recent version. (Still not sure why the other ways didn’t work, but anyway: this worked!)

Let me add the following two remarks still, may this be helpful for others in the future:

  • After doing this upgrade I actually ran into another issue with my Jupyter notebook, causing an error message when running dataframe.info(). I now apparently had an incompatible version of numpy; this issue is described here on StackOverflow, including the solution of running python -m pip install numpy==1.19.5 in an Anaconda prompt.
  • Yes, I am using Seaborn for my heatmap. The issue I ran into requires an update of matplotlib though, which is e.g. described here.
1 Like

Cool!

Most of time using Pip or Pip3 make better the job

This is so sick! Think Anaconda dsitribution has a lot of issues, this is not normal to always have incompatible issues between packages like that. Recently I removed Anaconda because of bugs and since now I cannot reinstall it (it’s not able to rebuild the menu commands), I have decided to work without Anaconda.

1 Like

I suspect you’re not using Anaconda as you should. You should do your best to avoid mixing conda and pip.

Running python -m pip install is a more robust way of installing libraries than using pip directly when using Anaconda.

The Python command will choose the right Python version.

In any case, conda update matplotlib would probably have saved you this hassle. Anaconda is a package manager. You have it installed, so it’s recommended you use it to manage your packages (this includes installing new ones and updating old ones).

2 Likes

Thank you for the elaboration! On a next occasion, I will try with conda update <....> in that case.

Do you need that specific version of matplotlib, or are you trying to just update it to the newest?

I’m not sure if you’re supposed to run conda commands in jupyter, I’m not sure that functionality is there.
Usually you can use pip inside of your OS’s command line interface(bash,powershell, etc) before you get into the actual python terminal. Your package managers are seperate.
also like others mentioned, you do not want to mix using pip and conda.

If you need specific versions of packages then I would use a virtualenvironment, put all your required versions into a requirements.txt file and inside of the virtual environment have conda or pip install those specific packages.
This allows you to run specific package versions inside of their own virtualized ‘containers’… if you have done everything else correctly and you are still having issues with your packages then this should be your next step

Hi @jaygbc12 , a belated “thank you!” for your additional comments to my question. (I was unavailable for some time, therefore not able to respond sooner). To answer your question about the version that I was looking for: I was first trying to install a next (specific) version of which I had read it should contain the bug fix that I needed. Then, since I didn’t get that to work, I just updated without specifying a version (using one of the suggestions given in this thread).