py2exe 数据文件 [英] py2exe data_files

查看:33
本文介绍了py2exe 数据文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的 python 程序构建一个可执行文件,如下所示:

I am trying to build an executable for my python program like so:

from distutils.core import setup
import py2exe, sys, os 
import matplotlib
import numpy
from glob import glob

sys.argv.append('py2exe')

datafiles = [('files', glob(r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*'))]

setup(windows=['main.py'], data_files= datafiles, options={"py2exe": {"includes": ["matplotlib"]}})

这可行,但是,我还需要包含通过此命令获得的这些 matplotlib 文件,以使程序正常工作:

This works, however, I need to include these matplotlibfiles obtained by this command as well in order to make the programm work:

matplotlib.get_py2exe_datafiles()

但不知何故我无法将它们包含到 data_files 中......我尝试了如下内容,但我收到了诸如元组"对象没有属性拆分"之类的错误

But somehow I am not able to include them into the data_files... I tried stuff like the following, but I am getting errors like "tuple' object has no attribute 'split'"

mpl = [('files', [matplotlib.get_py2exe_datafiles()])]
datafiles.append(mpl)

此外,在没有 matplotlibfiles 的情况下编译工作版本后,我收到一条警告,指出我的项目依赖于其他几个 dll - 有没有办法将它们一次性全部加入程序?

Also, after compiling the working version without the matplotlibfiles, I get a warning that my project is depending on several other dlls - is there any way to force them all at once into the program?

感谢您的帮助!

推荐答案

我设法完成了以下工作:

I managed to do get the following working:

datafiles = [("Microsoft.VC90.CRT", glob(r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*'))]
datafiles.extend(matplotlib.get_py2exe_datafiles()) 

setup(windows=['main.py'], data_files= datafiles, options={"py2exe": {"includes": ["matplotlib"]}})

感谢您的回复,这为我指明了正确的方向!

Thanks for your responses, which pointed me into the right direction!

这篇关于py2exe 数据文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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