简体   繁体   中英

Error installing PyQt5 library: unresolved reference

I'm trying to create a browser using Python and the library PyQt5

I installed correctly the library but i don't know why components can't be found. Is there a reason why the components can't be found? Thank you in advance

This is my code

import PyQt5
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtNetwork import *
import sys
from optparse import OptionParser


class MyBrowser(QWebPage):
''' Settings for the browser.'''

def userAgentForUrl(self, url):
    ''' Returns a User Agent that will be seen by the website. '''
    return "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"


class Browser(QWebView):
    def __init__(self):
       # QWebView
       self.view = QWebView.__init__(self)
       # self.view.setPage(MyBrowser())
       self.setWindowTitle('Loading...')
       self.titleChanged.connect(self.adjustTitle)
       # super(Browser).connect(self.ui.webView,QtCore.SIGNAL("titleChanged 
(const QString&)"), self.adjustTitle)

   def load(self, url):
       self.setUrl(QUrl(url))

   def adjustTitle(self):
       self.setWindowTitle(self.title())

   def disableJS(self):
      settings = QWebSettings.globalSettings()
      settings.setAttribute(QWebSettings.JavascriptEnabled, False)


app = QApplication(sys.argv)
view = Browser()
view.showMaximized()
view.load("https://pythonspot.com")
app.exec_()

This is where i get the error "Unresolved reference" 这个

First, try to uninstall it from cmd:

pip uninstall pyqt5

then install it again:

pip install pyqt5

if it still not working try this method:

1) Install the binary file Qt 5.0.2 for Windows 64-bit (VS 2012, 500 MB) from here .

2) Get sip-4.14.7 (development snapshot) from here .

3) Extract the file and open the Developer Command Prompt for VS2012 .

4) Execute these commands (in sip folder):

python configure.py
nmake
nmake install

5) Get the pyQt5 from here .

6) Extract the file and open the VS2012 x64 Native Tools Command Prompt .

7) Execute these commands:

python configure.py

I try it before and work for me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM