部署应用程序时,“matplotlib"没有属性“cm" [英] 'matplotlib' has no attribute 'cm' when deploying an app
问题描述
我正在尝试部署使用 Dash 开发的应用程序,该应用程序使用一些 matplotlib 函数.当我在本地运行应用程序时,它运行顺利,一切正常,但是,当我使用相同的代码(我正在使用 heroku 部署)部署它时,安装的 matplotlib 版本(当前的 2.2.3)不再找到属性"cm"以创建颜色图.
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')
实际结果
Matplotlib 版本
Matplotlib version
我使用的是 Windows 10,在本地和部署中使用 matplotlib 2.2.3,并且在本地,我的 Python 版本是 3.6.6.
I'm using Windows 10, with matplotlib 2.2.3 locally and in the deploy and, locally, my Python version is 3.6.6.
谢谢!
亲切的问候,热南
推荐答案
您需要导入 matplotlib.cm
才能工作.
You need to import matplotlib.cm
for this to work.
import matplotlib.cm
cmap = matplotlib.cm.get_cmap('Reds')
这篇关于部署应用程序时,“matplotlib"没有属性“cm"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!