I'm trying to create an exe file with PyInstaller (one-file mode). My program is a single file (usingTry.py). It's a super simple file that instantiates a class called "TrySystem" from an egg file I created. The "TrySystem" class loads an XRC file and places a bitmap button in it using wxPython. The XRC and the image files are saved as inner egg resources, as described in Managing resources in a Python project
I prepare my egg on a mac (10.8.5):
sudo python setup.py bdist_egg
I then copy it to a winXP machine (actually it runs on the same compoter as a VM) and install it:
easy_install Try\try2\dist\try3-1.0-py2.7.egg
When I then try to run "python usingTry.py" from the python terminal (on WinXP), all works fine and I see the frame and the button. I then go on to prepare an exe file from "usingTry.py" (on WinXP):
Try\users\usingTry>pyinstaller.py -F usingTry.py
And then I try to run it:
Try\users\usingTry>dist\usingTry.exe
Traceback (most recent call last):
File "<string>", line 11, in <module>
File "<string>", line 4, in __init__
File "z:\Documents\workspace\python\Try\users\usingTry\build\pyi.win32\usingTry\out00-PYZ.pyz\try3", line 35, in __init__
File "z:\Documents\workspace\python\Try\users\usingTry\build\pyi.win32\usingTry\out00-PYZ.pyz\try3", line 8, in __init__
File "z:\Documents\workspace\python\Try\users\usingTry\build\pyi.win32\usingTry\out00-PYZ.pyz\wx._core", line 7981, in __init__
File "z:\Documents\workspace\python\Try\users\usingTry\build\pyi.win32\usingTry\out00-PYZ.pyz\wx._core", line 7555, in _BootstrapApp
File "z:\Documents\workspace\python\Try\users\usingTry\build\pyi.win32\usingTry\out00-PYZ.pyz\try3", line 14, in OnInit
File "z:\Documents\workspace\python\Try\users\usingTry\build\pyi.win32\usingTry\out00-PYZ.pyz\pkg_resources", line 868, in resource_filename
File "z:\Documents\workspace\python\Try\users\usingTry\build\pyi.win32\usingTry\out00-PYZ.pyz\pkg_resources", line 181, in get_provider
File "c:\programs\pyinstaller-2.0\PyInstaller\loader\iu.py", line 409, in importHook
raise ImportError("No module named %s" % fqname)
ImportError: No module named try3.resources
Does someone know how to resolve this? In this link is a zip file with everything:
try.zip:
Try/
try2/ (this is the code that creates the egg)
setup.py
ez_setup.py
try3/ (the egg's code)
__init__.py
resources/ (here are the resource files used in the egg)
__init__.py
main.xrc
stopButton.png
build/
... (files created while I built the egg)
dist/
try3-1.0-py2.7.egg (the prepared egg file)
try3.egg-info/
...
users/
usingTry/ (here is the code that uses the egg file)
usingTry.py
usingTry.spec
dist/
usingTry.exe (created by "pyinstaller -F usingTry.py")
try3/ (I manually copied it here from Try/try2/ so the exe file works)
build/ (created by PyInstaller)
...
logdict2.7.5.final.0-1 (created by PyInstaller)
You'll notice that the folder Try\try2\try3 (which contains the egg's code) was manually copied to where the created exe file is (Try\users\usingTry\dist). That's because it makes the exe file work. I found this workaround in PyInstaller generated exe not working, project uses ReportLab
What I'd like to do is avoid this workaround and that things will simply work. It has to be somehing very simple as it's declared in the PyInstaller website that they fully support using egg files.