【问题标题】:Issue with matplotlib and cx_freezematplotlib 和 cx_freeze 的问题
【发布时间】:2017-02-06 22:15:33
【问题描述】:

我正在尝试冻结一个基于控制台的程序,该程序使用 matplotlib.pyplot 来生成和保存绘图。 (我不需要在保存之前预览或查看绘图。)这是我的 setup.py 脚本:

from cx_Freeze import setup, Executable
import os

os.environ['TCL_LIBRARY'] = "C:\\Program Files\\Anaconda3\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Program Files\\Anaconda3\\tcl\\tk8.6"

setup(name='FLOUResence.exe',
    version='0.1',
    options = {"build_exe": {"packages":["pandas", "numpy", "scipy", "matplotlib"]}
           },
executables = [Executable(script='caller.py', targetName='FLOUResence.exe', 
icon="icon.ico", base='Console')]
)

我可以编译程序,但是当我运行绘图模块时,它返回以下错误:

此应用程序无法启动,因为它无法找到或加载 Qt 平台插件“windows” 在“”中。
重新安装应用程序可能会解决此问题。

据我所知,因为 matplotlib 想要加载/使用 Qt GUI,但因为它是一个控制台应用程序 cx_freeze 不加载 Qt?这是对问题的正确解释吗?关于如何解决这个问题的任何想法?

【问题讨论】:

    标签: python matplotlib cx-freeze


    【解决方案1】:

    您需要将 Qt 平台插件添加到您的分发目录。试一试,将 PyQt 安装的 Library\plugins\platforms 复制到您的 package/dist 目录。如果这对您有用,您可以在 include_files 构建选项中添加目录。我正在使用 miniconda,所以平台目录位于 c:\miniconda\Library\plugins

    setup(name='FLOUResence.exe',
        version='0.1',
        options = {
            "build_exe": {"packages":["pandas", "numpy", "scipy", "matplotlib"],
                          "include_files": [r'c:\miniconda\Library\plugins\platforms']}
        },
        executables = [Executable(script='caller.py', targetName='FLOUResence.exe', 
                       icon="icon.ico", base='Console')]
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多