I get the following error if I create a QWebEngineView instance from Python instances in different working directories:
JavaScript
x
5
1
[2452:9872:1108/052617.050:ERROR:cache_util_win.cc(21)] Unable to move the cache: Access is denied. (0x5)
2
[2452:9872:1108/052617.050:ERROR:cache_util.cc(135)] Unable to move cache folder C:UsersAdamAppDataLocalpythonQtWebEngineDefaultGPUCache to C:UsersAdamAppDataLocalpythonQtWebEngineDefaultold_GPUCache_000
3
[2452:9872:1108/052617.051:ERROR:disk_cache.cc(184)] Unable to create cache
4
[2452:9872:1108/052617.056:ERROR:shader_disk_cache.cc(606)] Shader Cache Creation failed: -2
5
JavaScript
1
6
1
from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets
2
from PyQt5.QtCore import Qt
3
app = QtWidgets.QApplication([])
4
x = QtWebEngineWidgets.QWebEngineView()
5
x.load(QtCore.QUrl('http://example.com/'))
6
It seems this is a known issue and will be fixed in QT6: https://bugreports.qt.io/browse/QTBUG-66014
But in the meantime, how can I suppress this message? I tried changing QtCore.qInstallMessageHandler
and also x.page().javaScriptConsoleMessage = lambda self, level, msg, line, sourceID: None
, neither affected this message.
Advertisement
Answer
One possible solution is to raise the level of the chromium log:
JavaScript
1
8
1
import os
2
from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets
3
4
os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--enable-logging --log-level=3"
5
app = QtWidgets.QApplication([])
6
x = QtWebEngineWidgets.QWebEngineView()
7
# ...
8