Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spyder v3.0.0b3 gives QOpenGLShader errors during startup #3226

Closed
ilayn opened this issue Jun 15, 2016 · 40 comments
Closed

Spyder v3.0.0b3 gives QOpenGLShader errors during startup #3226

ilayn opened this issue Jun 15, 2016 · 40 comments

Comments

@ilayn
Copy link

ilayn commented Jun 15, 2016

First of all, thanks a lot for the fast fixes regarding the (Py)Qt5 problems. I really appreciate it.

What steps will reproduce the problem?

  1. Initiate spyder from the terminal
  2. Splashscreen counts the tasks and disappear
  3. A proper titlebar and a window is setup however inside is completely empty (black)

What is the expected output? What do you see instead?
Instead of the window panes nothing appears and the terminal repeats the following

""
QOpenGLShaderProgram::uniformLocation( qt_Matrix ): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed: 
""

Versions and main components

  • Spyder Version: 3.0.0b3
  • Python Version: 3.5.1
  • Operating system: Linux Mint 17
  • PyQt5 : 5.6 (via PyQt5.QtCore.PYQT_VERSION_STR)
  • QT5 : 5.5.1 (via PyQt5.QtCore.QT_VERSION_STR)

I also have Python 3.4 installed and I'm not sure which one is picked up by Spyder but python3 maps to 3.4.

Dependencies

N/A

@ilayn
Copy link
Author

ilayn commented Jun 15, 2016

Right click shows all the relevant menu options and I can visualize the layout based on the menu choices. Hence this looks like a rendering problem.

I have updated my Qt to version 5.6 and it is still the same.

@ilayn ilayn changed the title Spyder v3.0.0b3 gives QOpenShader errors during startup Spyder v3.0.0b3 gives QOpenGLShader errors during startup Jun 15, 2016
@ccordoba12
Copy link
Member

I don't know where this problem could be coming from, sorry.

@ilayn
Copy link
Author

ilayn commented Jun 16, 2016

This turns out to be a NVIDIA driver issue. I have found other instances across different projects suffering from the same wrong selection of libgl.so with dlopen; a bug report from python-pyqt4 is described here

The graphics card I have is GeForce GT 550M (optimus-based) and if I switch to the onboard Intel graphics card or switch to nouveau drivers it starts up and displays correctly.

There is no current solution unfortunately for this.

@ilayn ilayn closed this as completed Jun 16, 2016
@ilayn
Copy link
Author

ilayn commented Jun 28, 2016

I have no idea why this is happening but I'll write down what I did whether it is relevant or not (because I don't know what has changed). First I basically added the Ubuntu graphics ppa

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update

Then I installed the newest NVIDIA driver (367.27 at the time of writing) via Driver Manager. Then I have unlinked the symbolic link in the following directory. You can first check the result of

ldconfig -p | grep libGL.so

to see whether it is indeed still linked to mesa drivers. Hence, I used the following

cd /usr/lib/x86_64-linux-gnu/
sudo unlink libGL.so

After this I've used the solution given in AskUbuntu.SE

>> update-alternatives --display i386-linux-gnu_gl_conf

i386-linux-gnu_gl_conf - manual mode
  link currently points to /usr/lib/nvidia-367/alt_ld.so.conf
/usr/lib/i386-linux-gnu/mesa/ld.so.conf - priority 500
  slave i386-linux-gnu_xorg_extra_modules: /usr/lib/i386-linux-gnu/xorg/x11-extra-modules
/usr/lib/nvidia-367-prime/alt_ld.so.conf - priority 8603
/usr/lib/nvidia-367/alt_ld.so.conf - priority 8604
Current 'best' version is '/usr/lib/nvidia-367/alt_ld.so.conf'.

and then using

sudo update-alternatives --config i386-linux-gnu_gl_conf

first selected Nvidia-367-prime in the list and then one more time selecting the mesa drivers. Now all works properly.

Obviously I don't know which step (probably the very last one) made it working but for the more knowledgeable people this might give a clue.

@ccordoba12
Copy link
Member

@ilayn, thanks for letting us know about it :-)

@xxblx
Copy link

xxblx commented Oct 10, 2016

I have same issue. Fedora 24, x86_64, Nvidia GTX 550 Ti with driver NVIDIA 367.44

Instructions by @ilayn doesn't work for me. But I found another solution.

Adding

from OpenGL import GL

into site-packages/spyder/app/start.py solves problem. Now Spyder starts fine. But it creates +1 dependency - pyopengl.

@mherrmann3
Copy link

mherrmann3 commented Jan 25, 2017

I did @ilayn's suggestion (selecting the mesa driver) but it didn't quite work. Related to that: the same file can be edited manually, see Ultimaker/Cura#131 (comment) - found it thanks to @ilayn's launchpad link:

cd /etc/ld.so.conf.d
I found many conf files, including i386-linux-gnu_GL.conf and x86_64-linux-gnu_GL.conf
cat x86_64-linux-gnu_GL.conf
/usr/lib/nvidia-340-updates
/usr/lib32/nvidia-340-updates
... but i386-linux-gnu_GL.conf is empty. So I just copied the contents in x86_64-linux-gnu_GL.conf to i386-linux-gnu_GL.conf
sudo ldconfig
Everything is OK now☺

(due to @ilayn's suggestion, the i386-linux-gnu_GL.conf contained a reference to the mesa driver which I overwrote)

This worked! (and I don't need to put the from OpenGL import GL in spyder's start.py anymore)

@ilayn
Copy link
Author

ilayn commented Jan 25, 2017

As Peter Wurtz mentioned in the linked LaunchPad page, it is sad to see that this is still not fixed.

@drammock
Copy link

I just hit this bug too when trying to switch to running Spyder with qt5/py3 instead of qt4/py2. I realize this problem is not the fault of spyder devs... the discussion on launchpad makes it clear that the problem is that PyQt opens libGL.so, which on some systems is a link to the MESA GL library, not the NVIDIA GL library. The NVIDIA drivers should have changed that link to point to the NVIDIA library when they were installed, but didn't. As a result, PyQt is loading the wrong GL library. The above solution mentioned by @xxblx also works for me, because the pyopengl library loads libGL.so.1 (the NVIDIA library that libGL.so is supposed to link to but doesn't) and apparently once it's loaded PyQt won't try to load it again, so the incorrect MESA library doesn't get invoked.

I acknowledge that this is a workaround, but what exactly is the problem with adding from OpenGL import GL into app/start.py as a temporary work-around, until the upstream bug gets fixed?

@ccordoba12
Copy link
Member

but what exactly is the problem with adding from OpenGL import GL into app/start.py as a temporary work-around, until the upstream bug gets fixed?

Certainly none, we were unsure that this was the right fix.

@drammock, would you mind to create a PR with this fix? Please do it against the 3.1.x branch, so we can include it in 3.1.4. Thanks!

@drammock
Copy link

@ccordoba12 I'll try to get to this today or tomorrow.

@ilayn
Copy link
Author

ilayn commented Feb 23, 2017

We have to be careful though not all systems are affected by this and a workaround can break existing functional systems. I would really recommend having opinions of other users with different setups.

@madsthoudahl
Copy link

bumped into the same bug today,
using spyder 3.1.4, GeforceGTX1070, ubuntu gnome 17.04 and nvidia driver version 381.22.
@xxblx 's solution adding 'from OpenGL import GL' into start.py does not solve my problem

@The-Compiler
Copy link

I'm not sure I fully understand the issue, but couldn't the correct library be loaded by using ctypes rather than relying on PyOpenGL (which uses ctypes under the hood too)?

Would something like this work maybe?

import ctypes
ctypes.cdll.LoadLibrary("libGL.so.1")

or maybe:

ctypes.CDLL("libGL.so.1", mode=ctypes.RTLD_GLOBAL)

could someone who's affected by this bug try to remove the from OpenGL import GL workaround and test this instead?

@xxblx
Copy link

xxblx commented Jul 18, 2017

@The-Compiler

  1. add from OpenGL import GL into site-packages/spyder/app/start.py - starts fine
  2. remove from OpenGL import GL - segfault on start
  3. add
import ctypes
ctypes.CDLL("libGL.so.1", mode=ctypes.RTLD_GLOBAL)

starts fine
4. replace ctypes.CDLL("libGL.so.1", mode=ctypes.RTLD_GLOBAL) with ctypes.cdll.LoadLibrary("libGL.so.1") - segfault on start.

Fedora 26, Spyder 3.1.4, Dell XPS 13 (only intel video)

@The-Compiler
Copy link

Awesome, thanks for testing! Someone at qutebrowser/qutebrowser#2821 (comment) confirmed the same too. Looks like we have a simpe pure-Python workaround then 😉

@ilayn
Copy link
Author

ilayn commented Jul 18, 2017

@The-Compiler This is also mentioned in the launchpad link mentioned above but I don't think this is generic enough for some. There was another forum page back then which I can't find now that mentioned that this wasn't working for them. I think the best course of action is to press on the fix on the nvidia/pyqt dev side.

@The-Compiler
Copy link

Oh, I must've missed that. I've asked some more people to test, and the ctypes workaround seemed to work for them as well FWIW... I don't think a fix from nvidia is likely to happen, seeing that it's been almost 5.5 years now.

@ilayn
Copy link
Author

ilayn commented Jul 18, 2017

Yes I agree, pyqt people didn't even acknowledged that this is a bug which is strange to say the least.

@The-Compiler
Copy link

Probably because it isn't a PyQt bug 😉 libGL.so should point at the same library as libGL.so.1, just like with any other library.

@ilayn
Copy link
Author

ilayn commented Jul 18, 2017

Oh yes what I mean is that they could also help to point to this problem but anyways.

@olusis
Copy link

olusis commented Apr 18, 2018

Kernel: 4.13.0-38-generic
OS: Ubuntu 17.10 64bit

For me adding:
from OpenGL import GL in site-packages/spyder/app/start.py resulted in missing python module OpenGL.

Installed missing package:
conda install PyOpenGL
And spyder runs like a charm.

However, all worked before I installed QtCreator and for OpenGL libraries for OpenGL vidget.
Basically spyder stopped working after:

apt-get install libgl1-mesa-dev libglu1-mesa-dev

@RinaldoB
Copy link

RinaldoB commented Apr 20, 2018

Anaconda 5.1 with python=2.7, spyder=3.2.8, qt=5.9.5

import ctypes
ctypes.CDLL("libGL.so.1", mode=ctypes.RTLD_GLOBAL)

in site-packages/spyder/app/start.py fixed the problem for me.

Interestingly start.py already contains:

# This import is needed to fix errors with OpenGL when installed using pip
# See issue 3332
try:
    from OpenGL import GL
except:
    pass

but this does not not help as PyOpenGL is not a spyder dependency and is not installed in my Anaconda distribution.

Can I safely remove the mesa drivers (libegl1-mesa, libgl1-mesa-glx) now?

@d-rams
Copy link

d-rams commented Apr 25, 2018

Ubuntu 17.10 64, kernel 4.13, Anaconda 4.5.1, python 3.6, spyder 3.2.8, qt 5.9.5, nvidia 390.48, 1080ti

import ctypes
ctypes.CDLL("libGL.so.1", mode=ctypes.RTLD_GLOBAL)

works for me as well.

@d-rams
Copy link

d-rams commented Apr 25, 2018

In my case the lines

# This import is needed to fix errors with OpenGL when installed using pip
# See issue 3332
try:
    from OpenGL import GL
except:
    pass

in the start.py file can be removed with no effect.

@billwhiteley
Copy link

billwhiteley commented Apr 25, 2018

just installing PyOpenGL worked for me

conda install pyopengl

@lucis13
Copy link

lucis13 commented May 19, 2018

I also encounter this problem after using conda update --all
I have tried

import ctypes
ctypes.CDLL("libGL.so.1", mode=ctypes.RTLD_GLOBAL)

conda install pyopengl

none of them work for me.

@ProgramItUp
Copy link

I was getting:
QOpenGLShaderProgram::uniformLocation( qt_Matrix ): shader program is not linked .... QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked ..... QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked .....

then doing:

conda install pyopengl

I started getting:
ME@remoteHost:~$ ~/anaconda3/bin/spyder QXcbConnection: XCB error: 145 (Unknown), sequence: 171, resource id: 0, major code: 139 (Unknown), minor code: 20 The X11 connection broke: No error (code 0) XIO: fatal IO error 0 (Success) on X server "localhost:14.0" after 915 requests (915 known processed) with 0 events remaining.

This is occurring using MobaXterm 10.5 connecting to Ubuntu 16 and Centos 7 remote hosts.

Any suggestions?

@brennanyama
Copy link

brennanyama commented Jun 2, 2018

Hi all,

Just wanted to add that I experienced this bug on Ubuntu 16.04, but it was solved using @xxblx solution by adding:

from OpenGL import GL

to site-packages/spyder/app/start.py.

Some things to note: I am running anaconda3 (so Python 3.6), but I replicated this bug inside of a Python 2.7 environment. Interestingly, when I am in my Python 3.6 environment, Spyder works fine, but when I try to launch it inside of my Python 2.7 environment, Spyder throws the bug described in this thread. I am running a Nvidia GTX 1070 (on a laptop) on driver 384.130.

In my base (Python 3.6) environment, I am running Spyder 3.2.6
In my Python 2.7 (bugged) environment, I am running Spyder 3.2.8

Note that I did need to install OpenGL into my Python 2.7 environment in order for this fix to work (I did not have it installed originally). I did this using:

conda install pyopengl=3.1.1a1

inside my Python 2.7 environment.

Edit: actually, as described by @RinaldoB, the lines:

# This import is needed to fix errors with OpenGL when installed using pip
# See issue 3332
try:
    from OpenGL import GL
except:
    pass

Are already inside my start.py file. They didn't do anything because OpenGL was not installed on my system (the except condition was thrown). After simply installing OpenGL in the manner I described above, the bug is fixed without the need for adding:

from OpenGL import GL

to my start.py file.

In summary, for most people, I believe all you need to do is install OpenGL into the python environment that's demonstrating this bug, and it should fix.

@ProgramItUp
Copy link

@brennanyama: Thanks for the informative post.

Looks like I'm out of luck for a pre-built version for Power 9 achitecture.

$ ~/anaconda3/bin/conda install pyopengl=3.1.1a1
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
pyopengl=3.1.1a1
Current channels:
https://repo.continuum.io/pkgs/main/linux-ppc64le
https://repo.continuum.io/pkgs/main/noarch
https://repo.continuum.io/pkgs/free/linux-ppc64le
https://repo.continuum.io/pkgs/free/noarch
https://repo.continuum.io/pkgs/r/linux-ppc64le
https://repo.continuum.io/pkgs/r/noarch
https://repo.continuum.io/pkgs/pro/linux-ppc64le
https://repo.continuum.io/pkgs/pro/noarch
`

@brennanyama
Copy link

@ProgramItUp:
I'm no expert, but what version of spyder are you running? (conda list in terminal).
And what version of Python are you running? (python --version in terminal)

If you type conda search pyopengl, then conda should search for all of the versions of OpenGL it has available, and if you conda install pyopengl (I see you already did this), conda should be smart enough to install the most up-to-date version that is compatible with your Python binary--double check this to make sure you're understanding everything correctly.

Alternatively, if that doesn't work you can try install opengl using pip. That would be something along the lines of:

pip install pyopengl

conda should play nice with pip, but the general advice is to install the conda version of a package if it is available for both pip and conda.

@danieltremblaysher
Copy link

Hoping I can take advantage of the knowledge built-up around this issue instead of starting a new one I have the exact problem described by the OP except I'm running on a Windows 7 environment, so the libgl.so fixes do not apply. More details:

On Windows 7 Enterprise 64 bit (7601), Intel Graphics 2000 (with latest drivers), DX 11.
Fresh install of anaconda3, then spyder, then conda update --all just to be sure.

Problem exactly as described by OP (splashscreen, followed by black window but with appropriate mouse-overs, interactions, etc..). Also same error messages in console.

In this case:
python 3.6.5
spyder 3.2.8
qt 5.9.5
pyqt 5.9.2

After researching the issue, I also installed pyopengl (3.1.1a1). The start.py contained the try: from opengl import gl except pass lines already. Just for fun I eliminated the try/except block and no change.

My understanding is that this is a Qt issue (that may have popped up around 5.6->5.7?), but I haven't found a windows 7 specific solution.

Any suggestions?

@toofo
Copy link

toofo commented Jun 20, 2018

@olusis thank you so much!
conda install PyOpenGL #fixed similar issue

@lillux
Copy link

lillux commented Jun 27, 2018

@olusis thanks for your answer, it fixed spyder on the same issue.

Kubuntu 16.04, nvidia 860m, Driver Version: 384.130, Spyder 3.2.8

@randyzwitch
Copy link

Like above, conda install pyopengl worked for me on Ubuntu 16.04 from a clean conda py3.6 environment, no file editing necessary

@dennishnf
Copy link

Ubuntu 16.04 64, Anaconda 5.2.0, python 3.6, Spyder 3.3.0, Nvidia GeForce GTX 460

Add at the beggining of the file /home/<USER_NAME>/anaconda3/lib/python3.6/site-packages/spyder/app/start.py:

import ctypes
ctypes.CDLL("libGL.so.1", mode=ctypes.RTLD_GLOBAL)

works for me too.

*Note: On a virtual enviroment, the path is /home/<USER_NAME>/anaconda3/envs/<NAME_ENVIRONMENT>/lib/python3.6/site-packages/spyder/app/start.py

@grgsolymosi
Copy link

@ccordoba12 @randyzwitch
Ubuntu 16.04 from a clean conda py3.6 environment:
conda install pyopengl
no file editing necessary
Thank you randyzwitch! (and above someone)

airalcorn2 referenced this issue in airalcorn2/strike-with-a-pose Nov 30, 2018
@ghost
Copy link

ghost commented Sep 20, 2019

I had this problem, spyder was not starting when using a ssh connection and I had the error :
Could not initialize GLX.
This was because the qt version was to recent : 5.9

I could not solve it by installing pyopengl, nor any other fixes above.
Simply installing qt 5.6.2 (with conda -c conda-forge) did not work either because it downgraded my version of matplotlib to 2.2

I got it working by reinstalling a full conda environment to make sure I have the matplotlib version that I wanted : 3.1.1
conda install -c conda-forge matplotlib=3.1 qt=5.6.2 spyder

@erik-mansson
Copy link

While the above mentioned version fixes sound better, someone without the immediate ability to upgrade/reinstall may be interested in the workaround I found at https://stackoverflow.com/questions/42291236/python-spyder-could-not-initialize-glx/64848919#64848919 :

With Spyder 4.2.1 (Qt 5.12.10) on Debian and accessing from Windows with PuTTY and Xming 6.9.0.31 for X11-forwarding, launching Spyder initially failed with the printouts X server does not support XInput 2 and Could not initialize GLX.

Setting the environment variable
export QT_XCB_GL_INTEGRATION=none
made spyder work (within the same console session).

@YuMan-Tam
Copy link

Comment #3226 (comment) works perfectly. Thank you @erik-mansson! Seems that it's setting the environment variable is the key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests