简体   繁体   English

ImportError:无法从“matplotlib”导入名称“_png”

[英]ImportError: cannot import name '_png' from 'matplotlib'

I'm currently working with Python 3.7 on Pycharm and trying to get a better understanding of kivy.我目前正在 Pycharm 上使用 Python 3.7 并试图更好地了解 kivy。 I found a script that I'm trying to run but I'm encountering an import error: cannot import name '_png' from 'matplotlib'我找到了一个正在尝试运行的脚本,但遇到了导入错误:无法从“matplotlib”导入名称“_png”

Does anybody have any solution to this?有人对此有任何解决方案吗? Code below:下面的代码:

from matplotlib import use as mpl_use
mpl_use('module://kivy.garden.matplotlib.backend_kivy')

matplotlib version 3.1.0 did the trick for me. matplotlib 版本 3.1.0 为我解决了问题。

I am currently trying to key kivy to use bar charts from matplotlib in pycharm.我目前正在尝试键入 kivy 以使用 pycharm 中的 matplotlib 中的条形图。 If you could post your code that would be helpful.如果您可以发布您的代码,那将很有帮助。 I am very new to this, so if you could explain how you use the 3.1 version too我对此很陌生,所以如果你能解释一下你如何使用 3.1 版本

I have downgraded to 3.2.2 from 3.4.1 and it works for me.我已经从 3.4.1 降级到 3.2.2,它对我有用。 Using the python 3.9.使用 python 3.9。

I ran into a similar issue, and realized there were some incompatibilities with the imgaug version, so I downgraded from matplotlib version 3.5.2 to 3.4.2 and installed imgaug version 0.2.5.我遇到了类似的问题,并意识到与 imgaug 版本存在一些不兼容,因此我从 matplotlib 版本 3.5.2 降级到 3.4.2 并安装了 imgaug 版本 0.2.5。

Would advice you to check if you ran into some error msg while installing certain packages.建议您检查在安装某些软件包时是否遇到了一些错误消息。 And address them first and then follow up on the other errors.并首先解决它们,然后跟进其他错误。

Also ensure that the version downloaded is compatible with the other packages included in your project.还要确保下载的版本与项目中包含的其他包兼容。

Code Used:使用的代码:

!pip uninstall matplotlib !pip 卸载 matplotlib

.pip install matplotlib==3.4.2 .pip 安装matplotlib==3.4.2

!pip uninstall imgaug !pip 卸载 imgaug

.pip install imgaug==0.2.5 .pip 安装 imgaug==0.2.5

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 导入错误:无法从“matplotlib”导入名称“rcParams” - ImportError: cannot import name 'rcParams' from 'matplotlib' ImportError:无法从“matplotlib”导入名称“样式” - ImportError: cannot import name 'styles' from 'matplotlib' 无法从“matplotlib”导入名称“_png” - Cannot import name '_png' from 'matplotlib' 错误: from matplotlib import _png ImportError: cannot import name '_png' from 'matplotlib' (C:\\\\Garden\\lib\\site-packages\\matplotlib\\__init__.py) - Error: from matplotlib import _png ImportError: cannot import name '_png' from 'matplotlib' (C:\\Garden\lib\site-packages\matplotlib\__init__.py) 来自matplotlib导入样式ImportError:无法导入名称'style' - from matplotlib import style ImportError: cannot import name 'style' ImportError:无法导入名称mpl(从matplotlib导入mpl) - ImportError: cannot import name mpl (from matplotlib import mpl) 导入错误:无法导入名称'_path' matplotlib - ImportError: cannot import name '_path' matplotlib matplotlib:导入错误:无法导入名称“pyplot” - matplotlib: ImportError: cannot import name 'pyplot' matplotlib ImportError:无法导入名称'style' - matplotlib ImportError: cannot import name 'style' ImportError:无法在Kivy Matplotlib后端上从'matplotlib.font_manager'错误导入名称'weight_as_number' - ImportError: cannot import name 'weight_as_number' from 'matplotlib.font_manager' ERROR on Kivy Matplotlib backend
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM