简体   繁体   English

Py2exe将文件捆绑到单个exe中

[英]Py2exe bundling files into a single exe

I'm having some trouble getting Py2exe to bundle all the files into a single .exe. 我在让Py2exe将所有文件捆绑到一个.exe中时遇到麻烦。 It works fine for me when I don't bundle them together. 当我不将它们捆绑在一起时,对我来说效果很好。 So this is the setup.py script I use when I'm not bundling them together, and it always works: 所以这是我不将它们捆绑在一起时使用的setup.py脚本,它始终有效:

from distutils.core import setup
import py2exe
setup(console=['test.py'])

So I wanted to bundle all the files into a single executable, so I used this setup.py script for that, and this is the one that doesn't work: 因此,我想将所有文件捆绑到一个可执行文件中,因此我使用了setup.py脚本,但这是行不通的:

from distutils.core import setup
# I took this off the Internet
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
    options = {'py2exe': {'bundle_files': 1}},
    windows = [{'script': "test.py"}],
    zipfile = None,
)

When I run this script, a dist directory is created with the test.exe file. 当我运行此脚本时,将使用test.exe文件创建一个dist目录。 If I execute it by typing "test.exe" this error message pops up: 如果我通过键入“ test.exe”执行它,则会弹出此错误消息:

See the logfile 'c:\Python26\dist\test.ext.log' for details

And this is the contents of that logfile: 这是该日志文件的内容:

Traceback (most recent call last):
File "test.py", line 1, in <module>
EOFError: EOF when reading a line

So does anyone know how I can do this? 有人知道我该怎么做吗? I just want to bundle all the files Py2exe generates with test.py into a single executable. 我只想将Py2exe用test.py生成的所有文件捆绑到一个可执行文件中。 I know it can do this. 我知道它可以做到。 Or are there any other ways in which this can be done? 还是有其他方法可以做到这一点?

just from the errorlog message, could you try again after assuring the last line of test.py ends with a carriage return? 仅仅从错误日志消息中,您可以确保test.py的最后一行以回车结尾后重试吗? (press enter after the last line in test.py and save again) (在test.py的最后一行之后按Enter,然后再次保存)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM