gpt4 book ai didi

python - 当 matplotlib 工作正常时出现错误 : 'no module named ' matplotlib. style'

转载 作者:太空宇宙 更新时间:2023-11-03 16:34:59 24 4
gpt4 key购买 nike

我在带有 python3 的 ubuntu 14.04.1 LTS 上使用 PyCharm。我想使用“ggplot”样式模块,但收到“无名为模块”错误。 Matplotlib 1.3.1 已安装并且工作正常(我最近更新了它)。

import matplotlib as mpl
import matplotlib.style as mplstyle
mplstyle.use('ggplot')

ImportError: No module named 'matplotlib.style'

我还检查了 matplotlibrc 文件和 matplotlibtool,一切似乎都按照文档的建议进行。有人知道我能做什么吗?

最佳答案

根据What's new in matplotlib ,从 1.4 版本开始,matplotlib 中添加了 style 包。

因此,请检查您的 matplotlib 版本,

$ pip freeze | grep matplotlib
matplotlib==1.3.1

将 matplotlib 升级到最新版本,

$ sudo pip install matplotlib --upgrade

$ pip freeze | grep matplotlib
matplotlib==1.5.1

这对我来说效果很好。

import matplotlib.pyplot as plt
plt.style.use('ggplot')

关于python - 当 matplotlib 工作正常时出现错误 : 'no module named ' matplotlib. style',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37304414/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com