I am trying to package a program I wrote (using Pyqt4) into a single executable for linux. I tried using Pyinstaller however it has problems with importing Gio (for settings)
from gi.repository import Gio
Running the application would give:
ImportError: cannot import name Gio
I then tried to use bbFreeze. The problem here is that after compiling and running the application, I get this error message:
TypeError: GObject.__init__() takes exactly 0 arguments (1 given)
For bbFreeze this is my script I am running to compile the code:
#!/usr/bin/env python
from bbfreeze import Freezer
includes = ["gio"]
excludes = []
bbFreeze_Class = Freezer('dist', includes=includes, excludes=excludes)
bbFreeze_Class.addScript("main.py", gui_only=True)
bbFreeze_Class.use_compression = 0
bbFreeze_Class.include_py = True
bbFreeze_Class()
I am using Ubuntu 11.10 and Python 2.7. If someone can help that would be great. This is my first time writing Python and trying to compile it (so I am not sure if there are better alternatives).
You don't actually compile it, but merely package it. Compiling is where you translate your source code into machine-readable object code in the native instruction set of your computer. So for example, you compile C code into an executable.
Python isn't compiled, it's interpreted. But you can still execute them by prepending
#!/usr/bin/env python
to any script and marking it as executable.In terms of packaging a Python application for distribution, it's a little more of a hassle than you'd hope, but there are official instructions from Ubuntu.
As an aside, if you're developing with Ubuntu Quickly, it has a command for packaging.
Actually python supports packaging. You better look into distutils or setuptools for packaging your python package. I recommend python packaging to distro specific packaging as it will be usable in any distro. Also have a look at some projects which use these tools for packaging in pypi e.g Django.