Answer the question
In order to leave comments, you need to log in
How to fix import error in PyQT5 library?
I have a code where the following functions are imported from PyQT5:
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebKit import *
from PyQt5.QtWebKitWidgets import *
from PyQt5.QtWebEngine import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtNetwork import *
from PyQt5.QtCore import QUrl
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import QApplication
PyQt5==5.15.2
PyQt5-sip==12.8.1
PyQtWebEngine==5.15.2
Traceback (most recent call last):
File "headless_browser.py", line 6, in <module>
from PyQt5.QtWebKit import *
ModuleNotFoundError: No module named 'PyQt5.QtWebKit'
PyQt5==5.15.2
PyQt5-Qt5==5.15.2
PyQt5-sip==12.8.1
PyQtWebEngine==5.15.2
PyQtWebEngine-Qt5==5.15.2
Answer the question
In order to leave comments, you need to log in
It is strange that this is practically not written anywhere, but I found the following solution:
apt-get install python3-pyqt5.qtwebengine
apt-get install python3-pyqt5.qtwebkit
export QT_QPA_PLATFORM=offscreen
agent_2203 , what was your goal when you wrote this code? So that your program, copied to ubuntu, will take these libraries from somewhere and run? So after all, they need to be installed there, on ubuntu.
Or build a project on your computer that includes everything you need for it (there are many different programs, such as cx_Freeze, py2exe, nuitka, PyInstaller, etc., that do this). This is a non-trivial task, since most of the popular project builders have control stuck at the 1987 ini level...well, there it is.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question