CREASIG / QBANO

6 stars 6 forks source link

erreur python : module 'PyQt5.QtGui' has no attribute 'QApplication' #11

Open infoble opened 2 years ago

infoble commented 2 years ago

Bonjour,

depuis une récente mise à jour de qgis, j'ai l'erreur suivante lorsque je lance le géocodage : (Merci par avance)

Une erreur est survenue lors de l'éxécution du code Python: 

AttributeError: module 'PyQt5.QtGui' has no attribute 'QApplication' 
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\Python39\lib\urllib\request.py", line 1346, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "C:\OSGeo4W\apps\Python39\lib\http\client.py", line 1253, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\OSGeo4W\apps\Python39\lib\http\client.py", line 1299, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\OSGeo4W\apps\Python39\lib\http\client.py", line 1248, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\OSGeo4W\apps\Python39\lib\http\client.py", line 1008, in _send_output
    self.send(msg)
  File "C:\OSGeo4W\apps\Python39\lib\http\client.py", line 948, in send
    self.connect()
  File "C:\OSGeo4W\apps\Python39\lib\http\client.py", line 1422, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "C:\OSGeo4W\apps\Python39\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\OSGeo4W\apps\Python39\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\OSGeo4W\apps\Python39\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: A failure in the SSL library occurred (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users/jacques-b/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QBano\QBano_dialog.py", line 217, in coordonnees
    response = urllib.request.urlopen('https://api-adresse.data.gouv.fr/search/?' + url+'&limit=1')
  File "C:\OSGeo4W\apps\Python39\lib\urllib\request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "C:\OSGeo4W\apps\Python39\lib\urllib\request.py", line 517, in open
    response = self._open(req, data)
  File "C:\OSGeo4W\apps\Python39\lib\urllib\request.py", line 534, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "C:\OSGeo4W\apps\Python39\lib\urllib\request.py", line 494, in _call_chain
    result = func(*args)
  File "C:\OSGeo4W\apps\Python39\lib\urllib\request.py", line 1389, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "C:\OSGeo4W\apps\Python39\lib\urllib\request.py", line 1349, in do_open
    raise URLError(err)
urllib.error.URLError: 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users/jacques-b/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QBano\QBano_dialog.py", line 180, in geocoder
    coordonnees = self.coordonnees(adresse_complete, cp,insee,  city)
  File "C:\Users/jacques-b/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QBano\QBano_dialog.py", line 232, in coordonnees
    QMessageBox.critical(self, QtGui.QApplication.translate("QBAN(O)", "QBAN(O)"), QtGui.QApplication.translate("Internetconnexionerror", "Internet connexion error"), QMessageBox.Ok)
AttributeError: module 'PyQt5.QtGui' has no attribute 'QApplication'

Version de Python : 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] 
Version de QGIS : 3.22.3-Białowieża Białowieża, 1628765ec7 
infoble commented 2 years ago

En fait cette erreur se corrige en supprimant les 4 appels à QtGui dans les lignes 229 et 232 de QBano_dialog.py. QApplication étant appelé directement. Mais du coup la boite de dialogue de l'application peut afficher son erreur initiale qui est "erreur de connexion internet" pour chaque ligne... (la connexion est pourtant bonne)

Jas977 commented 1 year ago

Bonjour j'ai la meme erreur, comment est-ce possible de supprimer les lignes comme le preconise "infoble" ? voici mon erreur : `2023-01-26T16:47:45 WARNING Traceback (most recent call last): File "C:\Users/dinaw/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QBano\QBano_dialog.py", line 217, in coordonnees response = urllib.request.urlopen('https://api-adresse.data.gouv.fr/search/?' + url+'&limit=1') File "C:\PROGRA~1\QGIS31~1.11\apps\Python39\lib\urllib\request.py", line 214, in urlopen return opener.open(url, data, timeout) File "C:\PROGRA~1\QGIS31~1.11\apps\Python39\lib\urllib\request.py", line 523, in open response = meth(req, response) File "C:\PROGRA~1\QGIS31~1.11\apps\Python39\lib\urllib\request.py", line 632, in http_response response = self.parent.error( File "C:\PROGRA~1\QGIS31~1.11\apps\Python39\lib\urllib\request.py", line 561, in error return self._call_chain(args) File "C:\PROGRA~1\QGIS31~1.11\apps\Python39\lib\urllib\request.py", line 494, in _call_chain result = func(args) File "C:\PROGRA~1\QGIS31~1.11\apps\Python39\lib\urllib\request.py", line 641, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 400: Bad Request

         During handling of the above exception, another exception occurred:

         Traceback (most recent call last):
          File "C:\Users/dinaw/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QBano\QBano_dialog.py", line 180, in geocoder
          coordonnees = self.coordonnees(adresse_complete, cp,insee, city)
          File "C:\Users/dinaw/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QBano\QBano_dialog.py", line 229, in coordonnees
          QMessageBox.critical(self, QtGui.QApplication.translate("QBAN(O)", "QBAN(O)"), QtGui.QApplication.translate("Internetconnexionerror", "Internet connexion error"), QMessageBox.Ok)
         AttributeError: module 'PyQt5.QtGui' has no attribute 'QApplication'
         `