{"id":23881,"date":"2024-05-25T20:29:56","date_gmt":"2024-05-25T12:29:56","guid":{"rendered":"http:\/\/www.jdcui.com\/?p=23881"},"modified":"2024-05-25T21:49:31","modified_gmt":"2024-05-25T13:49:31","slug":"python-matplotlib-%e6%8f%90%e7%a4%ba-module-backend_interagg-has-no-attribute-figurecanvas","status":"publish","type":"post","link":"http:\/\/www.jdcui.com\/?p=23881","title":{"rendered":"[Python] matplotlib \u63d0\u793a\u9519\u8bef module &#8216;backend_interagg&#8217; has no attribute &#8216;FigureCanvas&#8217;"},"content":{"rendered":"<p><span style=\"color: #ff00ff; background-color: #ccffcc;\"><strong>\u5b9e\u5e72\u3001\u5b9e\u8df5\u3001\u79ef\u7d2f\u3001\u601d\u8003\u3001\u521b\u65b0\u3002<\/strong><\/span><\/p>\n<hr \/>\n<p>Python\u7f16\u7a0b\uff0c\u91c7\u7528matplotlib\u7ed8\u56fe\uff0c\u63d0\u793a\u4e00\u4e0b\u9519\u8bef\uff1a<\/p>\n<p><code>AttributeError: module 'backend_interagg' has no attribute 'FigureCanvas'. Did you mean: 'FigureCanvasAgg'?<\/code><\/p>\n<p>\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-23891\" src=\"http:\/\/www.jdcui.com\/wp-content\/uploads\/2024\/05\/FigureCanvas_1-min.png\" alt=\"\" width=\"979\" height=\"334\" srcset=\"http:\/\/www.jdcui.com\/wp-content\/uploads\/2024\/05\/FigureCanvas_1-min.png 979w, http:\/\/www.jdcui.com\/wp-content\/uploads\/2024\/05\/FigureCanvas_1-min-768x262.png 768w\" sizes=\"auto, (max-width: 979px) 100vw, 979px\" \/><\/p>\n<p>\u6839\u636e\u63d0\u793a\uff0c\u9519\u8bef\u539f\u56e0\u662f\u6ca1\u6709\u8bbe\u7f6e<code>FigureCanvas<\/code>\u53c2\u6570\uff0c\u8be5\u53c2\u6570\u7528\u4e8e\u6307\u5b9amatplotlib\u7684\u7ed8\u56fe\u540e\u7aef\u53c2\u6570backen\uff0c\u7ecf\u67e5\u8be2\uff0c\u91c7\u7528\u4ee5\u4e0b\u4e09\u53e5\u4ee3\u7801\u5f15\u7528matplotlib\u5e93\u5373\u53ef\u89e3\u51b3\u95ee\u9898<\/p>\n<pre><span style=\"color: #ff99cc;\">import matplotlib<\/span>\r\n<span style=\"color: #ff99cc;\">matplotlib.use('TkAgg')<\/span>\r\nimport matplotlib.pyplot as plt<\/pre>\n<p>\u5373\u5728\u4f7f\u7528matplotlib\u5e93\u524d\uff0c\u5148\u76f4\u63a5\u6307\u5b9abacken\u53c2\u6570\uff0c\u5176\u4e2d\uff0cmatplotlib\u7684backen\u53c2\u6570\u6709\u4ee5\u4e0b\u53ef\u9009\u9879<\/p>\n<pre>['GTK3Agg', 'GTK3Cairo', 'GTK4Agg', 'GTK4Cairo', 'MacOSX', 'nbAgg', 'QtAgg', 'QtCairo', 'Qt5Agg', 'Qt5Cairo', 'TkAgg', 'TkCairo', 'WebAgg', 'WX', 'WXAgg', 'WXCairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']<\/pre>\n<hr \/>\n<p><center><strong><div  class=\"thumbs-rating-container\" id=\"thumbs-rating-23881\" data-content-id=\"23881\"><button class=\"thumbs-rating-up thumbs-rating-voted\" onclick=\"thumbs_rating_vote(23881, 1);\">Vote Up +6<\/button> <button class=\"thumbs-rating-down\" onclick=\"thumbs_rating_vote(23881, 2);\">Vote Down -0<\/button><span class=\"thumbs-rating-already-voted\">You already voted!<\/span><\/div><\/strong><\/center><\/p>\n<ul style=\"list-style-type: square;\">\n<li><strong>\u76f8\u5173\u535a\u6587<span style=\"color: #0000ff;\">( Related Topics)<\/span><\/strong><\/li>\n<\/ul>\n<p><strong>[01].\u00a0<a title=\"Python \u51fa\u73b0\u201dinvalid literal for int() with base 10: \\xef\\xbb\\xbf0\u2033 \u9519\u8bef\" href=\"http:\/\/www.jdcui.com\/?p=6404\" target=\"_blank\" rel=\"noopener\">Python \u51fa\u73b0\u201dinvalid literal for int() with base 10: \\xef\\xbb\\xbf0\u2033 \u9519\u8bef<\/a><\/strong><\/p>\n<p><strong>[02].\u00a0<a title=\"[\u7f16\u7a0b\u7b14\u8bb0] Tuple in Python [Python\u4e2d\u7684\u5143\u7ec4]\" href=\"http:\/\/www.jdcui.com\/?p=6408\" target=\"_blank\" rel=\"noopener\">[\u7f16\u7a0b\u7b14\u8bb0] Tuple in Python [Python\u4e2d\u7684\u5143\u7ec4]<\/a><\/strong><\/p>\n<p><strong>[03].\u00a0<a title=\"[Python][\u7f16\u7a0b][\u7b14\u8bb0] Python\u6d77\u9f9f\u7ed8\u56fe \u2014\u2014 \u591a\u8fb9\u5f62 Polygon\" href=\"http:\/\/www.jdcui.com\/?p=18283\" target=\"_blank\" rel=\"noopener\">[Python][\u7f16\u7a0b][\u7b14\u8bb0] Python\u6d77\u9f9f\u7ed8\u56fe \u2014\u2014 \u591a\u8fb9\u5f62 Polygon<\/a><\/strong><\/p>\n<p><strong>[04].\u00a0<a title=\"[Python][\u7f16\u7a0b][\u7b14\u8bb0] Python\u7b26\u53f7\u8ba1\u7b97\u2014\u2014\u6c42\u504f\u5fae\u5206\u65b9\u7a0b (Python symbolic computation \u2014 solving partial differential equations)\" href=\"http:\/\/www.jdcui.com\/?p=18305\" target=\"_blank\" rel=\"noopener\">[Python][\u7f16\u7a0b][\u7b14\u8bb0] Python\u7b26\u53f7\u8ba1\u7b97\u2014\u2014\u6c42\u504f\u5fae\u5206\u65b9\u7a0b (Python symbolic computation \u2014 solving partial differential equations)<\/a><\/strong><\/p>\n<p><strong>[05].\u00a0<a title=\"[Python] \u5b89\u88c5PyOpenGL\u7b14\u8bb0\" href=\"http:\/\/www.jdcui.com\/?p=21529\" target=\"_blank\" rel=\"noopener\">[Python] \u5b89\u88c5PyOpenGL\u7b14\u8bb0<\/a><\/strong><\/p>\n<p><strong>[06].\u00a0<a title=\"[\u7f16\u7a0b][\u7b14\u8bb0] Python\u4e2dnumpy\u7684\u6c42\u548c\" href=\"http:\/\/www.jdcui.com\/?p=21800\" target=\"_blank\" rel=\"noopener\">[\u7f16\u7a0b][\u7b14\u8bb0] Python\u4e2dnumpy\u7684\u6c42\u548c<\/a><\/strong><\/p>\n<p><strong>[07].\u00a0<a title=\"[Python] matplotlib \u7ed8\u56fe\u5750\u6807\u8f74\u6807\u9898\u663e\u793a\u4e0d\u5168\" href=\"http:\/\/www.jdcui.com\/?p=23872\" target=\"_blank\" rel=\"noopener\">[Python] matplotlib \u7ed8\u56fe\u5750\u6807\u8f74\u6807\u9898\u663e\u793a\u4e0d\u5168<\/a><\/strong><\/p>\n<p><strong>[08]. <a title=\"[Python] matplotlib \u63d0\u793a\u9519\u8bef module \u2018backend_interagg\u2019 has no attribute \u2018FigureCanvas\u2019\" href=\"http:\/\/www.jdcui.com\/?p=23881\" target=\"_blank\" rel=\"noopener\">[Python] matplotlib \u63d0\u793a\u9519\u8bef module \u2018backend_interagg\u2019 has no attribute \u2018FigureCanvas\u2019<\/a><\/strong><\/p>\n<hr \/>\n<p style=\"text-align: center;\"><strong>\u7ed3\u6784|\u8d85\u9650|\u8f6f\u4ef6\u5f00\u53d1|\u7f16\u7a0b|\u53c2\u6570\u5316|\u4f18\u5316|\u7b97\u6cd5|\u632f\u52a8\u63a7\u5236|\u51cf\u9694\u9707|\u6709\u9650\u5143|\u6280\u672f\u57f9\u8bad<\/strong><\/p>\n<p style=\"text-align: center;\">\u8ffd\u6c42\u5353\u8d8a \u811a\u8e0f\u5b9e\u5730 \u81f4\u529b\u4e8e\u63a2\u7d22\u548c\u62d3\u5c55\u884c\u4e1a\u8bbe\u8ba1\u524d\u6cbf<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.jdcui.com\/wp-content\/uploads\/2017\/01\/QRCODE.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3636 alignnone\" src=\"http:\/\/www.jdcui.com\/wp-content\/uploads\/2017\/01\/QRCODE.jpg\" alt=\"WeChat_QRCode\" width=\"250\" height=\"255\" \/><\/a><\/p>\n<p style=\"text-align: center;\">https:\/\/www.jdcui.com<\/p>\n<p style=\"text-align: center;\">\u5408\u4f5c\u53ca\u6280\u672f\u54a8\u8be2<\/p>\n<p style=\"text-align: center;\">COOPERATION &amp; CONTACT<\/p>\n<p style=\"text-align: center;\">E-mail\uff1ajidong_cui@163.com<\/p>\n<p style=\"text-align: center;\">WeChat &amp; Tel: 13450468449<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9e\u5e72\u3001\u5b9e\u8df5\u3001\u79ef\u7d2f\u3001\u601d\u8003\u3001\u521b\u65b0\u3002 Python\u7f16\u7a0b\uff0c\u91c7\u7528matplotlib\u7ed8\u56fe\uff0c\u63d0\u793a\u4e00\u4e0b\u9519\u8bef\uff1a AttributeError: module &#8216;backend_interagg&#8217; has no attribute &#8216;FigureCanvas&#8217;. Did you mean: &#8216;FigureCanvasAgg&#8217;? \u5982\u4e0b\u56fe\u6240\u793a\uff1a \u6839\u636e\u63d0\u793a\uff0c\u9519\u8bef\u539f\u56e0\u662f\u6ca1\u6709\u8bbe\u7f6eFigureCanvas\u53c2\u6570\uff0c\u8be5\u53c2\u6570\u7528\u4e8e\u6307\u5b9amatplotlib\u7684\u7ed8\u56fe\u540e\u7aef\u53c2\u6570backen\uff0c\u7ecf\u67e5\u8be2\uff0c\u91c7\u7528\u4ee5\u4e0b\u4e09\u53e5\u4ee3\u7801\u5f15\u7528matplotlib\u5e93\u5373\u53ef\u89e3\u51b3\u95ee\u9898 import matplotlib matplotlib.use(&#8216;TkAgg&#8217;) import matplotlib.pyplot as plt \u5373\u5728\u4f7f\u7528matplotlib\u5e93\u524d\uff0c\u5148\u76f4\u63a5\u6307\u5b9abacken\u53c2\u6570\uff0c\u5176\u4e2d\uff0cmatplotlib\u7684backen\u53c2\u6570\u6709\u4ee5\u4e0b\u53ef\u9009\u9879 [&#8216;GTK3Agg&#8217;, &#8216;GTK3Cairo&#8217;, &#8216;GTK4Agg&#8217;, &#8216;GTK4Cairo&#8217;, &#8216;MacOSX&#8217;, &#8216;nbAgg&#8217;, &#8216;QtAgg&#8217;, &#8230;<\/p>\n","protected":false},"author":1,"featured_media":23891,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,997],"tags":[4182,998],"class_list":["post-23881","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","category-python","tag-matplotlib","tag-python"],"aioseo_notices":[],"views":4195,"_links":{"self":[{"href":"http:\/\/www.jdcui.com\/index.php?rest_route=\/wp\/v2\/posts\/23881","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.jdcui.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jdcui.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jdcui.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jdcui.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=23881"}],"version-history":[{"count":0,"href":"http:\/\/www.jdcui.com\/index.php?rest_route=\/wp\/v2\/posts\/23881\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.jdcui.com\/index.php?rest_route=\/wp\/v2\/media\/23891"}],"wp:attachment":[{"href":"http:\/\/www.jdcui.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=23881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jdcui.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=23881"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jdcui.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=23881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}