Search code examples
pythonopencvubuntuspyder

Python spyder could not initialize GLX


Trying to setup a desktop station for image processing. I recently installed ubuntu 16.04 and went through the guide by Adrian to install python3, cv2, and virtual enviroments.

Instead of using cv2 3.1.0, I used cv2 3.2.0 but besides that, everything was the same.

after installing correctly and running the various tests, I confirmed that python3 was working and cv2 was linked to python.

As I am used to graphical interfaces, I decided to install spyder as it has a nice GUI system. I have done this before on 2 separate devices (a laptop and a raspberry pi 3). However, upon installing on this desktop computer I ran into a weird problem.

When ever I run spyder, It results in the error below

  Could not initialize GLX
  Aborted (core dumped)

I have been looking online for solutions but I cannot seem to find an answer to this problem

edit: I went searching for core dump files on ubuntu and I found a bunch of files all containing the same code 00000033.


Solution

  • First of all, for our understanding:

    GLX (initialism for "OpenGL Extension to the X Window System") is an extension to the X Window System core protocol providing an interface between OpenGL and the X Window System as well as extensions to OpenGL itself. It enables programs wishing to use OpenGL to do so within a window provided by the X Window System. GLX distinguishes two "states": indirect state and direct state.

    Any way, I had a similar problem with QT installation and solved it installing the following package: libgl1-mesa-dri

    sudo apt-get install libgl1-mesa-dri
    

    Another similar solution I found was:

    sudo apt-get purge nvidia*
    sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.orig
    sudo rm /etc/X11/xorg.conf
    

    For 32-bit,

    sudo apt-get install --reinstall xserver-xorg-core libgl1-mesa-glx:i386 libgl1-mesa-dri:i386
    

    For 64-bit

    sudo apt-get install --reinstall xserver-xorg-core libgl1-mesa-glx:amd64 libgl1-mesa-dri:amd64
    
    sudo dpkg-reconfigure xserver-xorg
    

    I hope it helps you.