2016-03-06 53 views
1

见状后:Single-File Stand-alone Python 2.7.9 for Windows如何在Windows上创建单个文件的可执行文件python 2.7 x64?

我想为最新的Python 2.7.11 64类似的事情,但由于py2exe不支持在64位模式下单个文件的包装。我使用了cx_freeze,并成功生成了一个包,但cx_freeze没有单个文件选项。

所以我试着IExpress和7-zip sfx模块,但是它们都不能在同一个控制台上运行py.exe,并且它们不能将参数传递给解压缩后的exe文件。我还有什么其他选择?

这里是我的Python脚本: https://gist.github.com/oglops/a641b0185ed903ab1d1c

如果您尝试从原作者py.exe,它有一些命令行arguements,并在同一个控制台上运行,所以它可以像这样

使用
py.exe <some py script> 
+0

'pyinstaller --one文件<一些PY SCRIPT>' – zondo

+0

pyinstaller不起作用开箱即用,吨错误消息。因为原作者有他的setup.py。所以我先尝试了cx_freeze。 – Shuman

回答

1

首先,你需要安装pyinstaller可以得到这样的:

pip install pyinstaller 

然后从Python文件夹你generate the spec这样的:

pyinstaller --onefile --windowed myscript.py 

打开规范文件,并确保一切是正确的。

然后使用该规范来构建这样的应用程序:

pyinstaller.py --onefile myscriptsname.spec 

如果你得到这个错误层楼高的规格:

ImportError: No module named six

那么你还需要使用安装six这个:

pip install six 

six更多信息:

Six is a Python 2 and 3 compatibility library. It provides utility functions for smoothing over the differences between the Python versions with the goal of writing Python code that is compatible on both Python versions. See the documentation for more information on what is provided.

Six supports every Python version since 2.6. It is contained in only one Python file, so it can be easily copied into your project. (The copyright and license notice must be retained.)

+0

我收到了很多错误消息http://pastebin.com/JzFp37PC – Shuman

+0

你在哪一步得到错误?安装或构建规范或构建应用程序? –

+0

当建设规范 – Shuman

相关问题