py2app 构建的应用程序在其他计算机上显示“错误:pygame.macosx import FAILED”
尝试使用 py2app 在 Mac 上构建应用程序。在我的机器上一切正常,但是当将应用程序移动到另一台机器时,它崩溃并且控制台显示此错误。
错误:pygame.macosx import FAILED
有人有解决方案吗?
Trying to build an app on the Mac using py2app. Got everything working fine on my machine, but when moving the app to another, it crashes and the console displays this error.
ERROR: pygame.macosx import FAILED
Anybody have a solution to this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
几个小时后找到问题和解决方案。事实证明其他人也遇到过类似的问题,他们的文章非常有帮助:
http ://b.atcg.us/blog/2010/04/13/py2app-hell-the-first.html
http://www.vijayp.ca/blog/?p=62
如果其他人遇到此问题,则此特定问题是由于 Python 框架未捆绑到应用程序中而引起的。您可以通过右键单击应用程序查看包内容来确认这一点,然后继续转到 Contents/Frameworks/。如果 Python.framework 不存在,它应该存在。
请务必下载Python -
我的第一个问题是对 Apple 的 Python 包构建的依赖。不要使用这个。您需要安装您自己的 python 版本。转到 http://www.python.org/download/releases/,找到一个版本(我坚持使用 2.6 ),下载 gzip(不是 mac 软件包),如果您运行的是 Snow Leopard,请使用以下内容进行安装:
调整路径,安装软件包 - 从这里您需要调整路径以确保您是使用您的自定义安装版本。从这里,我重新安装了以下软件包 - 这结果是一个依赖性噩梦,所以我也包括了版本号:
如果这些软件包确实有效,您应该能够构建和现在运行您的应用程序。不幸的是,他们没有。我将稍后讨论错误和我的破解解决方案,但需要首先在构建文件中进行一些设置。
首先,setup.py 文件应该像这样:
setup.py
然后为了更加安全,我使用 shell 脚本来调用它。
build.sh
运行 build.sh 应编译该应用程序。如果它不能编译,我有个好消息——这不是你的错。由于库中的故障,您可能会遇到以下部分(或全部)问题:
潜在问题
如果构建脚本失败,请扫描回溯以查找以下某些关键字:
未找到 pygame - py2app 中的基本路径问题。 添加...。
在 py2app 库的 boot_app.py 中的 import 语句之后
pythonNone - 这似乎是 macho 包中的一个错误,它无法确定 python 构建的版本号。为了解决这个问题,我将以下几行添加到 py2app 中的 build_app.py 中。
没有这样的文件或目录...Python.framework/[lib|include] - py2app 只是查找文件系统树中更深层的目录。转到 Python.framework 目录并符号链接该位置...
应该可以了! - 这些步骤创建了一个可在其他英特尔计算机上运行的已编译应用程序。
Found the problem and solution after many hours. Turns out other people have experienced similar problems and their articles were quite helpful:
http://b.atcg.us/blog/2010/04/13/py2app-hell-the-first.html
http://www.vijayp.ca/blog/?p=62
In case someone else runs into the issue, this particular problem was caused because the Python framework was not being bundled into the application. You can confirm this by right-clicking your app to view package contents, then proceed to Contents/Frameworks/. If Python.framework is not there, it should be.
Be sure to download Python -
My first issue was reliance on Apple's build in Python package. Don't use this. You need to install your own version of python. Go to http://www.python.org/download/releases/, find a version (I stuck with 2.6), download the gzip (not the mac package), and install with the following if you are running Snow Leopard:
Adjust Paths, Install Packages - From here there you need to adjust your paths to ensure you are using your custom-installed version. From here, I reinstalled the following packages - this turned out to be a dependency nightmare so I'm including the version numbers as well:
If these packages actually worked, you should be able to build and run your app now. Unfortunately, they don't. I'll go into the errors and my hacked solutions in a bit, but there's some settings in the build file that need to be made first.
First the setup.py file should like a little somethin' like this:
setup.py
then to be extra safe, I use a shell script to call this.
build.sh
Running build.sh should compile the app. If it does not compile, I have good news -- it's not your fault. Due to glitches in the libraries, you may run into some (or all) of the following:
Potential Problems
If the build script fails, scan the traceback for some of the following keywords:
pygame not found - basic path problem in py2app. Add...
after the import statements in boot_app.py in the py2app lib.
pythonNone - This appears to be a bug in the macho package where it cannot determine the version number of your python build. To solve this, I added the following lines to build_app.py in py2app.
No such file or directory...Python.framework/[lib|include] - py2app is simply looking for directories that exist deeper in the file system tree. Go to the Python.framework directory and symlink up the place...
That should do it! - These steps created a compiled app that worked on other intel machines.
感谢您发布您发现的内容!
我有类似的问题。我尝试了您建议的各种组合,并为我隔离了一个问题,即您在上面确定的 boot_app.py 中的错误。
一旦我将一行修复添加到了上面提到的 boot_app.py 中,一切就都正常了,甚至使用预装的 Apple 版本的 python(版本 2.6.1)也是如此。
我应该注意,当我说“一切正常”时,我真正的意思是构建一个用于实际分发的 py2app 应用程序,即使用普通命令:
“别名”模式。即
py2app 文档建议在开发过程中使用,但仍然对我不起作用(具有相同的模块未找到错误)。但实际的发行版构建工作总比什么都没有好!再次感谢。
Thank you for posting what you found!
I had a similar problem. I tried various combinations of what you suggested, and isolated the single issue for me to be the bug in boot_app.py which you identify above.
Once I added the one-line fix to boot_app.py which you identify above, everything worked, even using the pre-installed Apple build of python (version 2.6.1).
I should note that when I say "everything worked," I really mean building a py2app app for actual distribution, i.e. using the normal command:
The "alias" mode. i.e.
which the py2app documentation suggests for use during development, still does not work for me (with the same module not found error). But better the actual distribution build working than nothing at all! Again, thanks.