便携式 Python(Mac -> Windows)

发布于 2024-09-30 02:42:36 字数 183 浏览 0 评论 0原文

我现在拥有一台可爱的 Macbook,我很享受在移动中编码的乐趣。我也喜欢用 Python 编码。不过,我想将最终结果作为可执行文件分发给使用 Windows 的朋友。

我知道 Py2Exe 可以做到这一点,但我不知道 Python 跨操作系统的可移植性如何。有人可以提供任何建议吗?我也在使用 PyGame。

非常感谢

I have a lovely Macbook now, and I'm enjoying coding on the move. I'm also enjoying coding in Python. However, I'd like to distribute the end result to friends using Windows, as an executable.

I know that Py2Exe does this, but I don't know how portable Python is across operating systems. Can anyone offer any advice? I'm using PyGame too.

Many thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

摇划花蜜的午后 2024-10-07 02:42:37

只要安装了解释器和相关库,Python脚本就具有相当的可移植性。生成的 .exe 和 .app 文件不是。

The Python scripts are reasonably portable, as long as the interpreter and relevant libraries are installed. Generated .exe and .app files are not.

倾城花音 2024-10-07 02:42:37

Py2exe 生成 Windows 可执行文件,因此它们只能在 Windows 平台上运行。 http://www.py2exe.org/index.cgi/FAQ 上的常见问题解答有有关这一切如何运作的更多信息。本质上,它提供了在 Win9x 以及更新的平台上运行所需的功能。注意:常见问题解答提到了一些字符编码的潜在问题和解决方法。

对于 python,它在基于 Unix 的系统上很常见,因为一些 Linux 发行版都有用该语言编写的自定义维护脚本。因此,Python 脚本将与 Ruby 脚本等一样可移植。只要目标计算机具有解释器,并且您没有使用仅在一种类型平台上的外部程序,其他人就可以使用您的工作。

Py2exe generates Windows executables, so they will only work on the Windows Platform. The FAQ at http://www.py2exe.org/index.cgi/FAQ has more information on how it all works. Essentially it provides what is needed to run on Win9x as well as more current platforms. NOTE: the FAQ mentions some potential gotchas with character encodings and the work arounds.

With python, it is common enough on Unix based systems, as several Linux distributions have their custom maintenance scripts written in the language. So the Python scripts will be just as portable as Ruby scripts, etc. As long as the target machine has the interpreter and you are not using external programs that are only on one type of platform, others will be able to use your work.

蓝海似她心 2024-10-07 02:42:37

就我个人而言,我在所有 Exe 构建器、py2exe、cx_freeze 等方面都遇到了巨大的困难。错误和错误一直存在,不断显示 atexit 模块的问题。

我发现包含 python 发行版更方便。除了易于使用之外,还有一个优点。

每次为 python 应用程序构建 EXE 时,您需要做的就是包含 python 安装的核心,但仅包含应用程序正在使用的模块。但即使在这种情况下,由于包含了 python 安装,您的应用程序也可能会从 python 模块的几 Kbs 增加到超过 15 mbs。

当然,安装整个 python 会占用更多空间,但每次发送 python 应用程序时,它们只有几 kb 长。另外,每次你对 python 应用程序进行更改(甚至是 coma)时,你都需要费力地捆绑 exe。或者我认为你这样做,我不知道仅仅替换 py 模块是否可以帮助你避免这种情况。

无论如何,安装 python 和 pygame 与在 Windows 中安装任何其他应用程序一样简单。在 Linux 中通过 synaptic 也非常容易。

不过 MACOS 有点棘手。 MACOS 已经预装了 python,Snow leopard 安装了 2.6.1 python。但是,如果您的应用程序使用晚于该版本的 python 并在您的应用程序中包含 python 的安装,则必须指示用户通过“获取信息 -> 打开方式”设置负责启动 python 的 python 启动器应用程序应用程序使用您的Python版本而不是板载默认的2.6.1版本,这并不困难,只需要几秒钟,即使是无知的用户也可以做到这一点。

Python具有极强的可移植性,Python pygame应用程序只能原样运行到三大平台,Windows,MACOS,Linux。它们甚至可以在移动和便携式设备上运行。如果您需要构建跨平台运行的应用程序,Python 非常简单并且强烈推荐。

Personally I experienced huge difficult with all the Exe builder, py2exe , cx_freeze etc. Bugs and errors all the time , keep displaying an issue with atexit module.

I find just by including the python distro way more convinient. There is one more advantage beside ease of use.

Each time you build an EXE for a python app, what you essential do is include the core of the python installation but only with the modules your app is using. But even in that case your app may increase from a mere few Kbs that the a python module is to more than 15 mbs because of the inclusion of python installation.

Of course installing the whole python will take more space but each time you send your python apps they will be only few kbs long. Plus you want have to go to the hussle of bundling the exe each time you change even a coma to your python app. Or I think you do , I dont know if just replacing the py module can help you avoid this.

In any case installing python and pygame is as easy as installing any other application in windows. In linux via synaptic is also extremly easy.

MACOS is abit tricky though. MACOS already come with python pre installed, Snow leopard has 2.6.1 python installed. However if you app is using a python later than that and include the install of python with your app, you will have to instruct the user to set via "GET INFO -> open with" the python launcher app which is responsible for launcing python apps to use your version of python and not the onboard default 2.6.1 version, Its not difficult and it only takes a few seconds, even a clueless user can do this.

Python is extremely portable, python pygame apps cannot only run unchanged to the three major platform , Windows , MACOS ,Linux . They can even run on mobile and portable devices as well. If you need to build app that runs across platform , python is dead easy and highly recomended.

歌枕肩 2024-10-07 02:42:37

如果您计划将 Linux 纳入您的可移植性标准,那么值得记住的是,许多发行版仍然打包 2.6(甚至 2.5),并且也可能是 3.x 系列中落后的版本(我假设您使用 2 .x 考虑到 PyGame 的要求)。

PyGame 的版本似乎在发行版之间也存在很大差异。

If you are planning to include Linux in your portability criteria, it's worth remembering that many distributions still package 2.6 (or even 2.5), and will probably be a version behind in the 3.x series as well (I'm assuming your using 2.x given the PyGame requirement though).

Versions of PyGame seem to vary quite heavily between distros as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文