将py2exe与wxPython和Matplotlib一起使用 [英] using py2exe with wxPython and Matplotlib

查看:64
本文介绍了将py2exe与wxPython和Matplotlib一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图从使用wxPython和Matplotlib的python脚本生成一个.exe文件,看来这是不可能的.

I'm trying to generate an .exe file from a python script that uses wxPython and Matplotlib and it looks like to be impossible.

我正在做的导入(与 Matplotlib 相关)如下:

The imports I'm doing (related with Matplotlib) are the following:

from numpy import *
导入 matplotlib
matplotlib.interactive(True)
matplotlib.use("WXAgg")
从matplotlib.figure导入图
从 matplotlib.backends.backend_wxagg 导入 FigureCanvasWxAgg 作为 FigCanvas
从matplotlib.ticker导入MultipleLocator

这是我尝试使用的 setup.py 文件:

Here is the setup.py file I'm trying to use:

from distutils.core import setup
import py2exe
import matplotlib

opts = {
'py2exe': {"bundle_files" : 3,
           "includes" : [ "matplotlib", 
            "matplotlib.backends",  
            "matplotlib.backends.backend_wxagg",
                        "numpy", 
                        "matplotlib.ticker",
                        "matplotlib.figure", "_wxagg"],
            'excludes': ['_gtkagg', '_tkagg', '_agg2', 
                        '_cairo', '_cocoaagg',
                        '_fltkagg', '_gtk', '_gtkcairo', ],
            'dll_excludes': ['libgdk-win32-2.0-0.dll',
                        'libgobject-2.0-0.dll']
          }
   }

setup(


  windows=[{'script':'starHunter.py', 'icon_resources':[(1, 'icon.ico')]}],

  data_files=matplotlib.get_py2exe_datafiles(),

  options=opts,

  zipfile=None
)

尝试运行成功创建的.exe文件后,我总是收到找不到matplotlib数据文件".

I'm always getting "Could not find matplotlib data files" after trying to run the .exe file, which by the way, is successfully created.

附加信息:我在 Windows XP 上使用 Python 2.6、Matplotlib 0.99.3、wxPython 2.8.11.0

Additional information: I'm using Python 2.6, Matplotlib 0.99.3, wxPython 2.8.11.0 on Windows XP

先谢谢了.任何帮助将不胜感激!

Thanks in advance. Any help will be appreciated!

干杯,Andressa Sivolella

Cheers, Andressa Sivolella

推荐答案

尝试使用 PyInstaller 而不是py2exe.它完全支持wxPython和matplotlib.与 py2exe 不同,它正在积极开发中.

Try using PyInstaller rather than py2exe. It has full support for wxPython and matplotlib. And it's in active development, unlike py2exe.

这篇关于将py2exe与wxPython和Matplotlib一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆