简体   繁体   English

打包适用于Windows 7的python可执行文件(64位)

[英]Packing python executable for Windows 7 (64bits)

I created a simple Python GUI (tkinter) program on Ubuntu and now I need to prepare an executable to run it on Windows 7. I tried to do that with Nuitka: 我在Ubuntu上创建了一个简单的Python GUI(tkinter)程序,现在我需要准备一个可执行文件才能在Windows 7上运行。我尝试使用Nuitka来做到这一点:

nuitka --recurse-all --standalone Menu.py

On Windows it didn't run. 在Windows上,它没有运行。 Am I doing sth wrong? 我做错了吗? Is it better to try other programs instead of Nuitka? 尝试使用其他程序代替Nuitka更好吗?

Edit: when I try to run it, Windows shows a dialog box with something like "this version of the program is not good for this Windows. Check if you are using 32 or 64 bits and contact the programmer." 编辑:当我尝试运行它时,Windows会显示一个对话框,内容为“此版本的程序不适用于该Windows。请检查您使用的是32位还是64位,并与程序员联系。”

Edit: I decided to do everything from Window using pyinstaller and it worked. 编辑:我决定使用pyinstaller从Window进行所有操作,并且可以正常工作。

Perhaps you should be using py2exe it is quite user friendly. 也许您应该使用py2exe,它非常用户友好。

Download py2exe here and follow the simple installer. 在此处下载py2exe 然后按照简单的安装程序进行操作。

Open your python command line and try import py2exe as long as this works the installation is successful. 打开Python命令行,并尝试import py2exe ,只要安装成功即可。

Don't forget to add the Python folder to your environment variables you can find a simple tutorial on environment variables here . 不要忘记将Python文件夹添加到您的环境变量中,您可以在此处找到有关环境变量的简单教程。

Let's now go through a simple example. 现在让我们来看一个简单的例子。

#hello.py
print "Hello World!"

python hello.py
Hello World!

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

python setup.py install
python setup.py py2exe

cd dist
hello.exe
Hello World!

You can view this tutorial here as well as more documentation. 您可以在此处查看本教程以及更多文档。

Hope this helps. 希望这可以帮助。

--lillypad --lillypad

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

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