I am converting my wxpython (3.0.2.0) application to binaries using PyInstaller. The binaries work fine when built and executed on Ubuntu 12.04. However if I build on Ubuntu 14.04, I get the following error. (The application works when I launch the python script directly i.e. python my_application.py even in Ubuntu 14.04). Any idea what could be missing when packaging the application using PyInstaller?
$ ./my_application
Traceback (most recent call last):
File "<string>", line 22, in <module>
File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "/local/workspace/my_application/out00-PYZ.pyz/wx", line 45, in <module>
File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "/local/workspace/my_application/out00-PYZ.pyz/wx._core", line 4, in <module>
**ImportError: No module named _core_**
My PyInstaller spec file looks like this:
...
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='my_application',
debug=False,
onefile = True,
strip=None,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
upx=True,
name='my_application')
Fundamentally the problem is with the PyInstaller version - you need to be on the develop
version. This issue has been seen and is documented on a PyInstaller Github issue.
To install the latest version and rectify - at the command prompt type:
$ pip install git+https://github.com/pyinstaller/pyinstaller
This directly installs the latest version of pyinstaller from github (this branch on github. Until recently, PyInstaller had a separate python3
branch, but this has been merged back into the develop
branch. If you need to use Python 3.x, you will need this branch - get this by appending @develop
to the pip install
command)
The above method relies on you having git
installed on your system to get the pyinstaller code (pretty likely for a developer these days, I guess). If not, you can either
apt-get install git
(you might need to sudo
that)Personally - I much prefer option 1 as you avoid all the potential problems of building from a zipped source tree yourself.
I tested this on Ubuntu 14.04, 64 bit, wxpython 3.0.2.0 with python 2.7.6, using the simple "Hello world" app from the wxPython webpage. The OP's issue reproduced exactly before installing pyinstaller develop version. After installing the develop version the app built correctly and ran as an executable.
Documentation of using pip with git - https://pip.pypa.io/en/latest/reference/pip_install.html#git
It is not clear from your question which versions of PyInstaller you are using on your Ubuntu 12.04 install vs the 14.04 version. It seems that the version you have on 12.04 does not exhibit the same issue as the standard version installed on 14.04.