且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法在python 3中导入matplotlib.pyplot

更新时间:2022-06-17 10:09:36

问题原因在mac os图像渲染中,matplotlib的后端(使用后端渲染的是什么)默认情况下为可可的API)。有Qt4Agg和GTKAgg,作为后端不是默认值。设置与其他Windows或linux操作系统相比不同的macosx后端。

Problem Cause In mac os image rendering back end of matplotlib (what-is-a-backend to render using the API of Cocoa by default). There is Qt4Agg and GTKAgg and as a back-end is not the default. Set the back end of macosx that is differ compare with other windows or linux os.

我按照以下方式解决了此问题:我假设您已经安装了pip matplotlib,您根目录中的目录称为〜/。 matplotlib。在其中创建一个名为matplotlibrc的文件,然后执行以下代码

I resolve this issue following ways I assume you have installed the pip matplotlib, there is a directory in you root called ~ /. matplotlib. Create a file called matplotlibrc there and following code

~ / .matplotlib / Matplotlibrc
backend: TkAgg