[PyQt] Workaround / fix for "could not create shader" issue with QtQuick on linux (causes all QtQuick examples to fail)

Russell Warren russ at perspexis.com
Mon Jan 27 22:17:31 GMT 2014

I had a hard time tracking this down and the 'solution' is somewhat hard to
find.  I'm sending this to get it out there a bit better and increase the
odds of other people finding it.

In short, the solution is: `pip install PyOpenGL` and then put `from OpenGL
import GL` at the top of any files you are having issues with.

Many thanks to Peter Wuertz for this fix!!  See: these links:

This is how the problem and solution look on my machine (using
pyqt/examples/quick/animation as my example):

$ python animation.py
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
Renderer failed shader compilation:
Segmentation fault
$ pip install PyOpenGL
Requirement already satisfied (use --upgrade to upgrade): PyOpenGL in
Cleaning up...
$ #add the OpenGL import at the top of the file (demonstration hack!)
$ sed -i '1ifrom OpenGL import GL\n' animation.py
$ python animation.py  #This now works perfectly!  Woohoo!
Segmentation fault

The segfault remains when you close the app, but at least QtQuick now
works!!  I'm not sure about the segfault yet, but am assuming it's along
the lines of this:

I saw some references indicating this could be due to old OpenGL drivers.
 In my case it is not.  For good measure:

$ glxinfo | grep "OpenGL version"
OpenGL version string: 3.3.0 NVIDIA 304.88

Also worth noting/confirming is that with my setup I had no issues getting
QtQuick it working in C++.  Only PyQt5 had problems.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140127/deecee43/attachment.html>

More information about the PyQt mailing list