2022.9.22 matplotlib + pyside2

matplotlib运行抛出问题:

  AttributeError: module 'backend_interagg' has no attribute 'FigureCanvas'. Did you mean: 'FigureCanvasAgg'?

  原因:matplotlib的backend的默认渲染器是agg,而agg是一个没有图像渲染的终端,需要切换终端TkAgg

  解决方法:matplotlib.use('TkAgg')

pyside2运行抛出问题:

  This application failed to start because no Qt platform plugin could be initialized

  原因:  1:环境变量配置问题;2:pyside2与其他第三方模块冲突;3:plugin,platforms文件损坏

  解决方法:1:进行环境配置

       2:在代码前指定环境变量 

        import os, sys

        dirname = os.path.dirname(PySide2.__file__)

        plugin_path = os.path.join(dirname, 'plugins', 'platforms')

        os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path

posted @ 2022-09-22 21:40  Robertup  阅读(106)  评论(0)    收藏  举报