PIL ImageTK does not load image into py2app application package

I am testing an application that I created that, among other things, loads a couple of .png images upon opening. Images display correctly on my Mac (10.7.5) and my mother (10.8.5); however, when my sister opens it on her (10.9.5), images are not uploaded. All other functions are otherwise intact. I should note that on my Mac and my mother I installed Python 3.4 and many of the packages that the application uses, including the PIL package, while my sister does not have any of them. The application was created using the command:

python3.4 setup.py py2app 

Images are imported into code using:

 image = ImageTk.PhotoImage(file = "images/pic.png") 

The setup file for py2app is as follows:

 from setuptools import setup APP = ['myapp.py'] DATA_FILES = [('', ['images'])] OPTIONS = {'iconfile': 'myapp.icns', 'packages': ['PIL']} setup( app=APP, data_files=DATA_FILES, options={'py2app': OPTIONS}, setup_requires=['py2app'], ) 

My guess is that this is a problem with PIL, it just doesn't want to play well with py2app. The reason I think it is PIL is because after running the command to create my application, I get the following error message in Terminal.

 Modules not found (conditional imports): * Image (/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/py2app/recipes/PIL/prescript.py) 

I would be very grateful for any suggestions or directions.

+6
source share
1 answer

If you create a python package that requires the installation of other packages, you can use the install_requires keyword in the settings to view documents . This has the additional advantage of installing the package (s) when the user runs pip install py2app. In your case, I would use install_requires = ['pillow'], and pip will automatically remove the pillow during the installation process.

0
source

All Articles