PyQt4: phonon… and on… and on

“App’ing up” PyQt… ugh.

One of biggest problems with PyQt is distributing it in a stand-alone package. Even worse… wanting to make your Qt plugins still function (Phonon, jpeg, etc). At work I constantly had this battle, along with my co-worker Tory. She actually has a long-standing issue with this, and had to resort to workarounds or half fixes. Here is Tory’s original post regarding the issue .

I would see an error similar to this when trying to package up and run an app using the Phonon module.

WARNING: bool Phonon::FactoryPrivate::createBackend() phonon backend plugin could not be loaded

Running macdeployqt does add things like the jpeg plugin, but never seemed to fix the Phonon issue. I finally decided to randomly look online for a solution, again, last week. What I found was a partial solution, followed by me trying one more thing and bam…it worked! Video playback from my .app standalone package.

Here is what I did …

(btw you might have to modify the location of the plugin, since I happen to be using OSX)

  1. In your file, which is used for py2app, py2exe, or similar… add this to the DATA_FILES list, so that it looks as such:

        DATA_FILES = [('phonon_backend', [

    This will put the phonon backend plugin into the RESOURCES folder in the app.

  2. Package up your application via py2app / py2exe / etc.

  3. If you are on OSX, use macdeployqt on the app: >>> macdeployqt

  4. Go into the app that was created (show package contents if you are on a mac), and move the phonon_backend directory FROM the Resources directory TO the PlugIns directory (which should be at the same level as Resources).

That should be it!