'matplotlib' has no attribute 'cm' when deploying an app

Viewed 4894

I'm trying to deploy an app developed using Dash which use some matplotlib functions. When I run locally the application, it runs smoothly and everything is okay, however, when I deploy it using the same code (I'm deploying using heroku) the matplotlib version that is installed (which is the current 2.2.3) no longer find the attrbute 'cm' to create a colormap.

import matplotlib
cmap = matplotlib.cm.get_cmap('Reds')

Actual Outcome

Logs of the heroku app

Matplotlib version

I'm using Windows 10, with matplotlib 2.2.3 locally and in the deploy and, locally, my Python version is 3.6.6.

Thank you!

Kind regards, Renan

2 Answers

You need to import matplotlib.cm for this to work.

import matplotlib.cm
cmap = matplotlib.cm.get_cmap('Reds')

Try:

import matplotlib.pyplot as plt
cmap = plt.cm.get_cmap('Reds')
Related