Py2app built an application that displays `ERROR: pygame.macosx import FAILED` on other machines

Trying to create an application on Mac using py2app. I got everything that works fine on my machine, but when I move the application to another, it crashes and the console displays this error.

ERROR: pygame.macosx import FAILED

Anyone have a solution?

+4
source share
2 answers

Found a problem and solution in many hours. It turns out that other people had similar problems, and their articles were very useful:

http://b.atcg.us/blog/2010/04/13/py2app-hell-the-first.html

http://www.vijayp.ca/blog/?p=62

In the event that someone else is having a problem, this particular problem was caused by the fact that the Python infrastructure was not included in the application. You can confirm this by right-clicking your application to view the contents of the package, and then go to Contents / Frameworks /. If Python.framework does not exist, it should be.

Be sure to download Python - My first problem was that Apple built the Python package. Do not use this. You need to install your own version of python. Go to http://www.python.org/download/releases/ , find the version (I'm stuck with 2.6), download gzip (not the mac package) and install with the following if you are using Snow Leopard:

 ./configure --enable-framework MACOSX_DEPLOYMENT_TARGET=10.6 --with-universal-archs=intel --enable-universalsdk=/ make sudo make install 

Customize paths, install packages . Here you need to customize your paths to make sure that you are using your own version. From here I reinstalled the following packages - this turned out to be a nightmare of dependency, so I also include version numbers:

  • py2app 0.5.2
  • macholib 1.3
  • modulegraph.8.0

If these packages really worked, you can create and run your application now. Unfortunately, they do not. Iโ€™ll work a bit with bugs and my hacked solutions, but first you need to create some settings in the build file.

First, the setup.py file should slightly resemble the following:

setup.py

 from setuptools import setup APP = ['Game.py'] DATA_FILES = ['data'] OPTIONS = { "argv_emulation": False, "compressed" : True, "optimize":2, "iconfile":'data/game.icns', } setup( app=APP, data_files=DATA_FILES, options={'py2app': OPTIONS}, ) 

then for extra security I use a shell script to call this.

build.sh

 ## Remove previous builds. Start with clean slate. rm -rf build dist ## Force python into 32 bit mode. export VERSIONER_PYTHON_PREFER_32_BIT=yes ## Force build with custom installed python /Library/Frameworks/Python.framework/Versions/2.6/bin/python setup.py py2app 

Running build.sh should compile the application. If it does not compile, I have good news - it is not your fault. Due to library crashes, you may encounter some (or all) of the following:

Potential Issues If the script build fails, trace scan for some of the following keywords:

pygame not found - main path issue in py2app. Add ...

 sys.path.insert(0, os.path.join(os.getcwd(), 'lib', 'python2.6','lib-dynload')) ## Added to fix dynlib bug 

after the import statements in boot_app.py in the py2app folder.

pythonNone . This is similar to a bug in the macho package where it cannot determine the version number of your python assembly. To solve this problem, I added the following lines to build_app.py in py2app.

 ## Add these two lines... if not info["version"]: info["version"] = "2.6" ## Before this line. (line 941 in method copy_python_framework() at time of writing) pydir = 'python%s'%(info['version']) 

There is no such file or directory ... Python.framework / [lib | include] - py2app just looks for directories that exist deeper in the file system tree. Go to the Python.framework directory and add a symlink ...

 cd /Library/Frameworks/Python.framework sudo ln -s Versions/Current/include/ include sudo ln -s Versions/Current/lib lib 

That should do it! . These steps created a compiled application that runs on other intel computers.

+13
source

Thanks for posting what you found!

I had a similar problem. I tried various combinations of what you suggested and isolated one problem for me like the error in boot_app.py that you indicated above.

As soon as I added the one-line fix to boot_app.py that you specified above, everything worked, even using the pre-installed Apple python build (version 2.6.1).

I should note that when I say โ€œeverything worksโ€, I really want to create a py2app application for actual distribution, that is, with the usual command:

 python setup.py py2app 

Alias โ€‹โ€‹mode. those.

 python setup.py py2app -A 

which the py2app documentation offers for use during development still does not work for me (no error was found with the same module). But better than the actual distribution than nothing! Thanks again.

+2
source

Source: https://habr.com/ru/post/1342382/


All Articles