title: sudo apt install python3-pyqt5 and other apt install methods
body: <p>here is the error.</p>
  <pre><code>QWebView is not defined
  </code></pre>
  <p>I am following along from a PyQt4 tutorial at <a href="https://wiki.python.org/moin/PyQt/Embedding%20Widgets%20in%20Web%20Pages" rel="nofollow noreferrer">https://wiki.python.org/moin/PyQt/Embedding%20Widgets%20in%20Web%20Pages</a>.</p>
  <p>I understand defining but what exactly should I define here and where should I define it?</p>
  <p>Where would I install QWebView?</p>
  <p>I know the link provided is a PyQt4 example and I am using PyQt5. I know there have been changes but I have not found exactly what the answer could be now.</p>
  <p>Here is some code:</p>
  <pre><code>import sys
  from PyQt5.QtCore import QSize, Qt
  from PyQt5.QtGui import *
  from PyQt5.QtWebKit import *
  from PyQt5.QtWidgets import *
  
  html = \
  &quot;&quot;&quot;&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Python Web Plugin Test&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;h1&gt;Python Web Plugin Test&lt;/h1&gt;
  &lt;object type=&quot;x-pyqt/widget&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;&lt;/object&gt;
  &lt;p&gt;This is a Web plugin written in Python.&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &quot;&quot;&quot;
  
  class WebWidget(QWidget):
  
      def paintEvent(self, event):
          painter = QPainter()
          painter.begin(self)
          painter.setBrush(Qt.white)
          painter.setPen(Qt.black)
          painter.drawRect(self.rect().adjusted(0, 0, -1, -1))
          painter.setBrush(Qt.red)
          painter.setPen(Qt.NoPen)
          painter.drawRect(self.width()/4, self.height()/4,
                           self.width()/2, self.height()/2)
          painter.end()
  
      def sizeHint(self):
          return QSize(100, 100)
  
  class WebPluginFactory(QWebPluginFactory):
  
      def __init__(self, parent = None):
          QWebPluginFactory.__init__(self, parent)
  
      def create(self, mimeType, url, names, values):
          if mimeType == &quot;x-pyqt/widget&quot;:
              return WebWidget()
  
      def plugins(self):
          plugin = QWebPluginFactory.Plugin()
          plugin.name = &quot;PyQt Widget&quot;
          plugin.description = &quot;An example Web plugin written with PyQt.&quot;
          mimeType = QWebPluginFactory.MimeType()
          mimeType.name = &quot;x-pyqt/widget&quot;
          mimeType.description = &quot;PyQt widget&quot;
          mimeType.fileExtensions = []
          plugin.mimeTypes = [mimeType]
          print(&quot;plugins&quot;)
          return [plugin]
  
  if __name__ == &quot;__main__&quot;:
  
      app = QApplication(sys.argv)
      QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
      view = QWebView()
      factory = WebPluginFactory()
      view.page().setPluginFactory(factory)
      view.setHtml(html)
      view.show()
      sys.exit(app.exec_())
  </code></pre>