将简单的 Python 脚本转换为 Windows 可执行文件的过程 [英] Process to convert simple Python script into Windows executable

查看:42
本文介绍了将简单的 Python 脚本转换为 Windows 可执行文件的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个脚本来帮助 Windows 用户的日常生活.我只想向她发送 .exe,而不是让她安装 python、dll 或必须处理任何其他文件.

I wrote a script that will help a Windows user in her daily life. I want to simply send her the .exe and not ask her to install python, dlls or have to deal with any additional files.

我已经阅读了大量有关将 Python 脚本编译为可执行文件的 stackoverflow 条目.我有点困惑,因为有很多选择,但有些似乎过时了(自 2008 年以来没有更新),而且没有一个足够简单,让我在花了几个小时之后现在不会问这个.

I've read plenty of the stackoverflow entries regarding compiling Python scripts into executable files. I am a bit confused as there are many options but some seem dated (no updates since 2008) and none were simple enough for me not to be asking this right now after a few hours spent on this.

我希望有一种更好的、最新的方法来做到这一点.

I'm hoping there's a better, up-to-date way to do this.

我调查了:

  • pylunch
  • py2exe
  • cx_Freeze
  • py2app (only for Mac)
  • pyinstaller
  • bbfreeze

但要么我无法让它们工作,要么无法理解如何获得我需要的结果.我得到的最接近的是 py2exe 但它仍然给了我 MSVCR71.dll

but either I couldn't get them to work or couldn't understand how to get the result I need. The closest I got was with py2exe but it still gave me the MSVCR71.dll

我希望得到分步回答,因为我也无法遵循此处的一些调整答案,这些答案需要事先了解如何使用 py2exe 或其他一些工具.

I would appreciate a step-by-step answer as I was also unable to follow some of the tweaking answers here that require some prior understanding of how to use py2exe or some of the other tools.

我使用的是 Python 2.5,因为其中一个模块仅适用于该版本.

I'm using Python 2.5 as one of the modules is only available for that version.

推荐答案

如果您使用 --onefile 选项,PyInstaller 将创建一个单文件可执行文件(尽管它实际所做的是提取然后运行本身).

PyInstaller will create a single-file executable if you use the --onefile option (though what it actually does is extracts then runs itself).

这里有一个简单的 PyInstaller 教程.如果您对使用有任何疑问,请留言...

There's a simple PyInstaller tutorial here. If you have any questions about using it, please post them...

这篇关于将简单的 Python 脚本转换为 Windows 可执行文件的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆