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

- WebGL is not supported by your browser - for scatter, line, scatter3d plots #74

Closed
brbatv opened this issue Jan 4, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@brbatv
Copy link

brbatv commented Jan 4, 2021

PLEASE FILL OUT THE TEMPLATE

Hello, thank you for this amazing app, it is really helpful.

Describe the bug

Some plots works and other don't. Histogram is fine, as well as Contour and Heatmap.

But the two main ones that I want to use (scatter, line) don't work and shows a message in the GUI when I click on the "Finish" button :

" WebGL is not supported by your browser - visit https://get.webgl.org for more info"

I think (not 100% sure) that i remember these types of plots were working like a week or two ago, but nothing really changed in my code since (no pip packages upgraded)

The python console says
WebEngineContext used before QtWebEngine::initialize() or OpenGL context creation failed.

each first time I use the function show() from pandasgui.
I think this message is related to the issue but I have no idea how to fix it.

Environment
OS: Mint 20 cinnamon
Python: 3.8.5 conda virtual envrionment
IDE: VsCode python interactive console by copy/pasting the code, OR by running the python script, same issue

Package versions

All packages installed : (collapsable content)

absl-py 0.10.0
aiodns 1.1.1
aiohttp 3.7.2
aiohttp-socks 0.5.5
aiorpcX 0.18.4
alabaster 0.7.12
analytics-python 1.2.9
ansi2html 1.5.2
appdirs 1.4.4
arbitragelab 0.1.0
argh 0.26.2
argon2-cffi 20.1.0
astroid 2.4.2
astunparse 1.6.3
async-generator 1.10
async-timeout 3.0.1
atomicwrites 1.4.0
attrs 20.2.0
autopep8 1.5.4
Babel 2.8.0
backcall 0.2.0
bitstring 3.1.7
bleach 3.2.1
bokeh 2.2.1
Bottleneck 1.3.2
Brotli 1.0.9
brotlipy 0.7.0
cachetools 4.1.1
ccxt 1.35.22
certifi 2020.12.5
cffi 1.14.3
chardet 3.0.4
click 7.1.2
cloudpickle 1.6.0
cryptography 3.1.1
cvxpy 1.1.1
cycler 0.10.0
Cython 3.0a6
dacite 1.6.0
dash 1.14.0
dash-bootstrap-components 0.10.3
dash-core-components 1.10.2
dash-cytoscape 0.2.0
dash-html-components 1.0.3
dash-renderer 1.6.0
dash-table 4.9.0
dask 2.28.0
decorator 4.4.2
defusedxml 0.6.0
diff-match-patch 20200713
distlib 0.3.1
distributed 2.28.0
dnspython 1.16.0
docutils 0.16
ecdsa 0.16.0
ecos 2.0.7.post1
Electrum 4.0.4
entrypoints 0.3
evdev 1.3.0
faster-than-csv 1.8
filelock 3.0.12
flake8 3.8.3
Flask 1.1.2
Flask-Compress 1.5.0
fsspec 0.8.3
future 0.18.2
gast 0.3.3
google-auth 1.21.3
google-auth-oauthlib 0.4.1
google-pasta 0.2.0
grpcio 1.32.0
h5py 2.10.0
HeapDict 1.0.1
helpdev 0.7.1
idna 2.10
imagesize 1.2.0
importlib-metadata 1.7.0
iniconfig 1.1.1
intervaltree 3.1.0
ipykernel 5.3.4
ipython 7.18.1
ipython-genutils 0.2.0
isort 5.5.4
itsdangerous 1.1.0
jedi 0.17.1
jeepney 0.4.3
Jinja2 2.11.2
joblib 0.16.0
json5 0.9.5
jsonschema 3.2.0
jupyter-client 6.1.7
jupyter-core 4.6.3
jupyter-dash 0.3.1
jupyter-kite 1.1.0
jupyterlab 2.2.9
jupyterlab-pygments 0.1.2
jupyterlab-server 1.2.0
Keras-Preprocessing 1.1.2
keyring 21.4.0
kiwisolver 1.2.0
lazy-object-proxy 1.4.3
lightgbm 3.1.1
llvmlite 0.32.1
locket 0.2.0
Markdown 3.2.2
MarkupSafe 1.1.1
matplotlib 3.2.1
mccabe 0.6.1
mistune 0.8.4
msgpack 1.0.0
multidict 5.0.0
nbclient 0.5.0
nbconvert 6.0.6
nbformat 5.0.7
nest-asyncio 1.4.1
networkx 2.4
notebook 6.1.4
numba 0.49.1
numpy 1.18.5
numpydoc 1.1.0
oauthlib 3.1.0
opt-einsum 3.3.0
osqp 0.6.1
packaging 20.4
pandas 1.0.4
pandasgui 0.2.7
pandocfilters 1.4.2
parso 0.7.0
partd 1.1.0
pathtools 0.1.2
patsy 0.5.1
pbr 5.5.1
pexpect 4.8.0
pickleshare 0.7.5
Pillow 7.2.0
pip 20.2.3
plotly 4.10.0
pluggy 0.13.1
postgres-binary-parser 0.0.0
POT 0.7.0
prometheus-client 0.8.0
prompt-toolkit 3.0.7
protobuf 3.13.0
psutil 5.7.2
psycopg2 2.8.6
ptyprocess 0.6.0
py 1.9.0
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycares 3.1.1
pycodestyle 2.6.0
pycparser 2.20
pydocstyle 5.1.1
pyflakes 2.2.0
Pygments 2.7.1
pylint 2.6.0
pynput 1.7.1
pyOpenSSL 19.1.0
pyparsing 2.4.7
PyQt5 5.15.2
PyQt5-sip 12.8.1
PyQtWebEngine 5.15.2
pyrsistent 0.17.3
PySocks 1.7.1
pytest 6.1.1
python-dateutil 2.8.1
python-jsonrpc-server 0.4.0
python-language-server 0.35.1
python-socks 1.1.0
python-xlib 0.29
pytz 2020.1
pyxdg 0.26
PyYAML 5.3.1
pyzmq 19.0.2
QDarkStyle 2.8.1
qrcode 6.1
QtAwesome 0.7.2
qtconsole 4.7.7
QtPy 1.9.0
requests 2.24.0
requests-oauthlib 1.3.0
retrying 1.3.3
rope 0.17.0
rsa 4.6
Rtree 0.9.4
scikit-learn 0.23.1
scipy 1.5.4
scs 2.1.2
SecretStorage 3.1.2
Send2Trash 1.5.0
setuptools 50.3.0
sip 4.19.13
six 1.15.0
snowballstemmer 2.0.0
sortedcontainers 2.2.2
Sphinx 3.2.1
sphinxcontrib-applehelp 1.0.2
sphinxcontrib-devhelp 1.0.2
sphinxcontrib-htmlhelp 1.0.3
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.3
sphinxcontrib-serializinghtml 1.1.4
spyder 4.1.5
spyder-kernels 1.9.4
SQLAlchemy 1.3.19
statsmodels 0.11.1
stevedore 3.3.0
tblib 1.7.0
tensorboard 2.2.2
tensorboard-plugin-wit 1.7.0
tensorflow 2.2.0
tensorflow-estimator 2.2.0
termcolor 1.1.0
terminado 0.8.3
testpath 0.4.4
threadpoolctl 2.1.0
toml 0.10.1
toolz 0.11.1
tornado 6.0.4
traitlets 5.0.4
typing-extensions 3.7.4.3
ujson 3.2.0
urllib3 1.25.10
virtualenv 20.2.2
virtualenv-clone 0.5.4
virtualenvwrapper 4.8.4
watchdog 0.10.3
wcwidth 0.2.5
webencodings 0.5.1
Werkzeug 1.0.1
wheel 0.35.1
wrapt 1.11.2
wurlitzer 2.0.1
yapf 0.30.0
yarl 1.6.2
zict 2.0.0
zipp 3.1.0

console.log("I'm a code block!");

Any help would be much appreciated. I did read this related issue but didn't find any fix for my case there #25

Thank you!

@brbatv brbatv added the bug Something isn't working label Jan 4, 2021
@brbatv brbatv changed the title - WebGL is not supported by your browser - for scatter, line, scatter3d - WebGL is not supported by your browser - for scatter, line, scatter3d plots Jan 4, 2021
@adamerose
Copy link
Owner

adamerose commented Jan 4, 2021

Yeah like you said this looks similar to #25 which I was unable to reproduce so couldn't debug myself. Try running this snippet below to confirm it's QWebEngineView failing to run WebGL content.

from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets

app = QtWidgets.QApplication([])

viewer = QtWebEngineWidgets.QWebEngineView()
viewer.load(QtCore.QUrl("http://webglreport.com/?v=2"))
viewer.show()

app.exec_()

Here are some fixes that you can try, let me know if they work

  • viewer.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.WebGLEnabled, True)
  • app = QtWidgets.QApplication(["--ignore-gpu-blacklist", "--enable-gpu-rasterization"])
  • Try another IDE if you're using PyCharm

Otherwise I recommend you post this snippet and your error to StackOverflow with the PyQt5 tags, and also to this forum https://forum.qt.io/category/10/general-and-desktop

If there's a fix that works for you I'll merge it into PandasGUI.

@brbatv
Copy link
Author

brbatv commented Jan 5, 2021

Hello, thank you for answering.
So I tried this snippet in a new script and it tells me everything is fine.
2021-01-05_09-27

One thing I just realized that I didn't tell in the original post is that when I import show from pandasgui, I get this message :

>>> from pandasgui import show
Qt WebEngine seems to be initialized from a plugin. Please set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before constructing QGuiApplication.
>>> 

And I noticed that if I run your snippet THEN do a from pandasgui import show, this warning doesn't show up.

So I just added from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets at the beginning of my original script, before from pandasgui import show, and now all plots are working and no warning messages !! So the issue is FIXED thanks to these prior imports !! Very happy.

👍 👍 👍

@adamerose
Copy link
Owner

Hm okay if that snippet works then this does seem different than the other issue. Are you able to reproduce the problem in a new script where you just open up a sample dataset and make a scatterplot?

from pandasgui import show
from pandasgui.datasets import pokemon
show(pokemon)

Or does the problem only happen with your original full script?

@brbatv
Copy link
Author

brbatv commented Jan 5, 2021

All right so here's new insights :

from pandasgui import show
from pandasgui.datasets import pokemon
show(pokemon)

gives no problem on a blank script. This was indeed a problem with my original script.
I found the issue so here is some reproducible code :

import pandas as pd 
# from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets # uncomment this line to fix the scattter plot issue

db=pd.read_csv('testfull') # only 'testfull' file gives the error, 'test' which is only a 4 row dataframe is not giving any error
import matplotlib.pyplot as plt

a=db.close+10
a.plot(legend=True)
b=db.close+20
b.plot(legend=True)
a=db.close+30
a.plot(legend=True)
a=db.close+50
a.plot(legend=True)
db.close.plot(secondary_y=True,legend=True)
plt.show()

from pandasgui import show
show(db) 

I uploaded two text files which are dataframes. The one named " test " is a very small and doesn't give the issue. The bigger version " testfull " has the WebGl error.
Obviously this has to do with conflicts with matplolib. If you remove all the .plot() parts, pandasgui is working fine. But it's strange that importing Qt packages before fixes this anyway.
dataframes.zip

By the way if you from pandasgui import show at the beginning of the file, the problem is also fixed.
Hope this helps.

@adamerose
Copy link
Owner

All right so here's new insights :

from pandasgui import show
from pandasgui.datasets import pokemon
show(pokemon)

gives no problem on a blank script. This was indeed a problem with my original script.
I found the issue so here is some reproducible code :

import pandas as pd 
# from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets # uncomment this line to fix the scattter plot issue

db=pd.read_csv('testfull') # only 'testfull' file gives the error, 'test' which is only a 4 row dataframe is not giving any error
import matplotlib.pyplot as plt

a=db.close+10
a.plot(legend=True)
b=db.close+20
b.plot(legend=True)
a=db.close+30
a.plot(legend=True)
a=db.close+50
a.plot(legend=True)
db.close.plot(secondary_y=True,legend=True)
plt.show()

from pandasgui import show
show(db) 

I uploaded two text files which are dataframes. The one named " test " is a very small and doesn't give the issue. The bigger version " testfull " has the WebGl error.

Thanks, this example gives the same error on my Windows 10 machine so I can debug.

Obviously this has to do with conflicts with matplolib. If you remove all the .plot() parts, pandasgui is working fine. But it's strange that importing Qt packages before fixes this anyway.

I suspect it might be related to this workaround where I temporarily kill the QApplication created by matplotlib's backend to allow importing QtWebEngineWidgets. It's supposed to warn you when this happens but I just noticed a problem with the logger so this didn't happen (that's fixed on the dev branch now).

The workaround seems to work fine in simple cases like below, but it breaks WebGL when it kills the QApplication created by matplotlib. I'll see if that can be fixed

from PyQt5 import QtWidgets
app = QtWidgets.QApplication([])
from pandasgui import show
from pandasgui.datasets import pokemon
show(pokemon)

@adamerose
Copy link
Owner

adamerose commented Jan 7, 2021

I think I found a fix here, interestingly just attempting to run from PyQt5 import QtWebEngineWidgets with an existing QApplication breaks OpenGL even inside a try/catch. So my workaround now uses if statements instead of try/catch, and your example works for me now. Let me know it doesn't for you (test the latest version with pip install git+https://github.com/adamerose/pandasgui.git)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants