几天前,我能够使用py2exe创建我的软件包的Windows可执行文件,没有任何问题。今天我在完成删除build/
和dist/
文件夹后再次尝试,但我没有看到任何错误,但我也没有在dist/
文件夹中获得可执行文件。我确实在dist/
:
这是我的setup.py
文件:
from setuptools import setup
import py2exe
setup (
name = "RabbitToRaven",
version = "0.1",
description="RabbitToRaven is a utility for copying RabbitMQ messages into a RavenDB database.",
author="Greg Major",
author_email="", # Removed to limit spam harvesting.
url="http://www.gregmajor.com/",
packages=['RabbitToRaven'],
entry_points = {
'console_scripts': ['RabbitToRaven = RabbitToRaven.__main__:main']
},
download_url = "http://www.gregmajor.com/",
zip_safe = True
)
如果我使用$ python setup.py build
运行export DISTUTILS_DEBUG=1
,那么我就明白了:
options (after parsing config files):
options (after parsing command line):
option dict for 'aliases' command:
{}
option dict for 'build' command:
{'verbose': ('command line', 1)}
running build
Distribution.get_command_obj(): creating 'build' command object
setting options for 'build' command:
verbose = 1 (from command line)
running build_py
Distribution.get_command_obj(): creating 'build_py' command object
creating build
creating build\lib
creating build\lib\RabbitToRaven
copying RabbitToRaven\__init__.py -> build\lib\RabbitToRaven
copying RabbitToRaven\__main__.py -> build\lib\RabbitToRaven
这是我的python setup.py py2exe
输出:
options (after parsing config files):
options (after parsing command line):
option dict for 'aliases' command:
{}
option dict for 'py2exe' command:
{}
running py2exe
Distribution.get_command_obj(): creating 'py2exe' command object
Distribution.get_command_obj(): creating 'bdist' command object
Distribution.get_command_obj(): creating 'build' command object
setting options for 'build' command:
running build_py
Distribution.get_command_obj(): creating 'build_py' command object
creating build
creating build\lib
creating build\lib\RabbitToRaven
copying RabbitToRaven\__init__.py -> build\lib\RabbitToRaven
copying RabbitToRaven\__main__.py -> build\lib\RabbitToRaven
creating c:\Users\Greg\Code\LeadPipe.RabbitToRaven\build\bdist.win-amd64
creating c:\Users\Greg\Code\LeadPipe.RabbitToRaven\build\bdist.win-amd64\winexe
creating c:\Users\Greg\Code\LeadPipe.RabbitToRaven\build\bdist.win-amd64\winexe\collect-2.7
creating c:\Users\Greg\Code\LeadPipe.RabbitToRaven\build\bdist.win-amd64\winexe\bundle-2.7
creating c:\Users\Greg\Code\LeadPipe.RabbitToRaven\build\bdist.win-amd64\winexe\temp
creating c:\Users\Greg\Code\LeadPipe.RabbitToRaven\dist
*** searching for required modules ***
*** parsing results ***
creating python loader for extension 'unicodedata' (C:\tools\python2\DLLs\unicodedata.pyd -> unicodedata.pyd)
creating python loader for extension 'select' (C:\tools\python2\DLLs\select.pyd -> select.pyd)
creating python loader for extension '_hashlib' (C:\tools\python2\DLLs\_hashlib.pyd -> _hashlib.pyd)
creating python loader for extension 'bz2' (C:\tools\python2\DLLs\bz2.pyd -> bz2.pyd)
*** finding dlls needed ***
*** create binaries ***
*** byte compile python files ***
byte-compiling C:\tools\python2\Lib\StringIO.py to StringIO.pyc
snip!!!
byte-compiling c:\Users\Greg\Code\LeadPipe.RabbitToRaven\lib\warnings.py to warnings.pyc
*** copy extensions ***
copying C:\tools\python2\DLLs\_hashlib.pyd -> c:\Users\Greg\Code\LeadPipe.RabbitToRaven\dist
copying C:\tools\python2\DLLs\bz2.pyd -> c:\Users\Greg\Code\LeadPipe.RabbitToRaven\dist
copying C:\tools\python2\DLLs\select.pyd -> c:\Users\Greg\Code\LeadPipe.RabbitToRaven\dist
copying C:\tools\python2\DLLs\unicodedata.pyd -> c:\Users\Greg\Code\LeadPipe.RabbitToRaven\dist
*** copy dlls ***
copying C:\Windows\system32\python27.dll -> c:\Users\Greg\Code\LeadPipe.RabbitToRaven\dist
setting sys.winver for 'c:\Users\Greg\Code\LeadPipe.RabbitToRaven\dist\python27.dll' to 'RabbitToRaven'
*** binary dependencies ***
Your executable(s) also depend on these dlls which are not included,
you may or may not need to distribute them.
Make sure you have the license if you distribute any of them, and
make sure you don't distribute files belonging to the operating system.
USER32.dll - C:\Windows\system32\USER32.dll
SHELL32.dll - C:\Windows\system32\SHELL32.dll
ADVAPI32.dll - C:\Windows\system32\ADVAPI32.dll
WS2_32.dll - C:\Windows\system32\WS2_32.dll
GDI32.dll - C:\Windows\system32\GDI32.dll
KERNEL32.dll - C:\Windows\system32\KERNEL32.dll
有人有想法吗?我对py2exe很新,所以我确定这可能只是一个愚蠢的疏忽。为了它的价值,我的virtualenv环境被激活,我正在构建一个Bash for Git终端(虽然cmd.exe
也不起作用。)
答案 0 :(得分:0)
您没有指定应将哪个文件制作成可执行文件。或者至少不是py2exe理解的方式。 entry_points
和console_scripts
似乎是setuptools独有的选项。
添加
console=['name_of_script.py']
或
windows=['name_of_script.py']
作为setup.py文件中setup()
函数的参数。取决于您是否正在创建控制台或GUI应用程序。这些必须是列表,即使您只指定了一个python脚本,但如果您愿意,可以添加更多。
假设您正在创建一个控制台应用程序,您的设置功能应该是这样的。
setup (
name = "RabbitToRaven",
version = "0.1",
console = ['name_of_script.py'],
...)
有关所有py2exe选项,请参阅http://www.py2exe.org/index.cgi/ListOfOptions。