2014-10-29 102 views
0

我在python3做了一个简单的应用程序,我只有一个窗口和一个按钮,与bdist命令试试:如何从linux生成.exe文件? Python的

python setup.py bdist --format=zip 

,但不是为我工作。

有:cx_Freeze

import sys 
from cx_Freeze import setup, Executable 

# Dependencies are automatically detected, but it might need fine tuning. 
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]} 

# GUI applications require a different base on Windows (the default is for a 
# console application). 
base = None 
if sys.platform == "win32": 
    base = "Win32GUI" 

setup( name = "guifoo", 
     version = "0.1", 
     description = "My GUI application!", 
     options = {"build_exe": build_exe_options}, 
     executables = [Executable("text.py", base=base)]) 

有任何意见或建议? 创建了一个文件夹,但我没有看到.exe 如果我使用的图像应放在哪里? 模块呢? 如果我使用相对路径会发生什么?

+0

你为什么要创建一个Linux发行版.exe文件? .exe文件只能在Windows中工作。你可以在linux中创建一个可执行文件,但不能创建一个.exe文件,尤其是使用Python。 – 2014-10-29 09:20:40

+0

哦,是因为我在Windows上编程,但在Linux上,假设python是多平台的,所以我应该能够为我的Debian Linux中的不同操作系统创建多个可执行文件? – grijalvaromero 2014-10-29 19:06:01

+0

@grijalvarmero这是可能的。 – 2014-10-29 22:20:54

回答

1

你累了吗PyInstaller

PyInstaller支持交叉编译:

增加支持交叉编译:PyInstaller现在能够在Linux下运行时建立的Windows可执行文件。请参阅文档了解更多详情

更多信息here


希望这有助于:)