Riverscapes / QRAVEPlugin

QGIS Plugin for viewing Riverscapes projects
0 stars 0 forks source link

OSGEO:QRAVE not installing with QGIS 3.28 - Can't find module lxml #86

Closed bbelletti closed 1 year ago

bbelletti commented 1 year ago

Error message thrown:

Impossible de charger l'extension 'qrave_toolbar' provoque une erreur lors de l'appel à sa méthode classFactory() 

ModuleNotFoundError: No module named 'lxml' 
Traceback (most recent call last):
  File "C:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 423, in _startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "C:\Users/belle/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qrave_toolbar\__init__.py", line 40, in classFactory
    from .src.qrave_toolbar import QRAVE
  File "C:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\Users/belle/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qrave_toolbar\src\qrave_toolbar.py", line 29, in 
    from .classes.basemaps import BaseMaps
  File "C:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\Users/belle/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qrave_toolbar\src\classes\basemaps.py", line 7, in 
    import lxml.etree
  File "C:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'lxml'

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.28.0-Firenze Firenze, ed3ad0430f3 

Chemin Python :
C:/OSGeo4W/apps/qgis/./python
C:/Users/belle/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/belle/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/OSGeo4W/apps/qgis/./python/plugins
C:\Program Files\QGIS 3.4\apps\Python37\Scripts
bbelletti commented 1 year ago

Same error with version 3.4.14

MattReimer commented 1 year ago

I have not been able to reproduce this on any version of QGIS so far on windows 10 64-bit

Here are the versions I've tried:

QGIS version
3.28.0-Firenze

QGIS version
3.26.3-Buenos Aires

QGIS version
3.16.10-Hannover

Questions:

Is this a fresh install? Have you customized the python paths or modules in any way? I see a reference to C:\OSGeo4W/ which makes me think your python interpreter may be referencing the wrong modules folder or something like that.

when you type import lxml in the python console in QGIS do you see an error?

You can try the following (again, inside the QGIS python console) to see which paths are being used by python

import sys
print(sys.path)
joewheaton commented 1 year ago

Is this a fresh install? Have you customized the python paths or modules in any way? I see a reference to C:\OSGeo4W/ which makes me think your python interpreter may be referencing the wrong modules folder or something like that.

@MattReimer I was working with @bbelletti (you will meet her in November) and had her post this. The Q3.4.14 is an older install, but the Q 3.28.0 was a brand new install. This is a windows machine, but it is configured for French.

@bbelletti are you able to

when you type import lxml in the python console in QGIS do you see an error?

You can try the following (again, inside the QGIS python console) to see which paths are being used by python

joewheaton commented 1 year ago

@MattReimer, for what it is worth, when I type in my Q 3.26.3 Python prompt import lxml, I get:

Traceback (most recent call last):
  File "C:\PROGRA~1\QGIS32~2.3\apps\Python39\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "C:\PROGRA~1/QGIS32~2.3/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'lxlml'

But my system is also successfully running and has QRAVE installed?

My sys.path returns:

import sys
print(sys.path)
['C:/PROGRA~1/QGIS32~2.3/apps/qgis/./python', 'C:/Users/joemw/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python', 'C:/Users/joemw/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python/plugins', 'C:/PROGRA~1/QGIS32~2.3/apps/qgis/./python/plugins', 'C:\\Program Files\\QGIS 3.26.3\\bin\\python39.zip', 'C:\\PROGRA~1\\QGIS32~2.3\\apps\\Python39\\DLLs', 'C:\\PROGRA~1\\QGIS32~2.3\\apps\\Python39\\lib', 'C:\\Program Files\\QGIS 3.26.3\\bin', 'C:\\PROGRA~1\\QGIS32~2.3\\apps\\Python39', 'C:\\PROGRA~1\\QGIS32~2.3\\apps\\Python39\\lib\\site-packages', 'C:\\PROGRA~1\\QGIS32~2.3\\apps\\Python39\\lib\\site-packages\\win32', 'C:\\PROGRA~1\\QGIS32~2.3\\apps\\Python39\\lib\\site-packages\\win32\\lib', 'C:\\PROGRA~1\\QGIS32~2.3\\apps\\Python39\\lib\\site-packages\\Pythonwin', 'C:/Users/joemw/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python']
MattReimer commented 1 year ago

@joewheaton you have a typo. it's not lxlml. It's lxml

and if QRave is working for you I would not expect an error as we depend on this library heavily. I haven't seen any evidence that lxml has been removed from QGIS or anything drastic like that so I suspect that what we're dealing with here is a configuration issue on one machine.

joewheaton commented 1 year ago

Also, for completeness, we did troubleshoot trying to uninstall and download a zip of a previous release and that didn't work either.

MattReimer commented 1 year ago

Yeah. I should probably refrain from making guesses without debugging thoroughly... but if I had to guess I'd say there's probably an environment variables set on the windows system or windows profile level that's setting PYTHONPATH to something it shouldn't be. This can cause QGIS to get confused about A) which modules to use and B) which version of python to use,.

joewheaton commented 1 year ago

So, for what its worth, on my system (which also has the lxml problem in its Python, when I go to System → About → Advanced System Settings → Advanced Tab → Environmental Variables, and reveal Path Settings, this is what I have: image

I can try and help troubleshoot @bbelletti tomorrow if we need it. Thanks @MattReimer.

MattReimer commented 1 year ago

@joewheaton I don't think you have the same problem, you just mis-typed lxml

from the error you sent me: ModuleNotFoundError: No module named 'lxlml'

Note the extra l?

joewheaton commented 1 year ago

Ha! Good catch @MattReimer. Moving to fast. The problem I have is typing.... accurately.

MattReimer commented 1 year ago

In the end this was not actually a problem. The OSGEO install makes you explicitly install python modules. Once we installed the correct ones (i.e. lxml, scipy and shapely) the plugin started working again.

joewheaton commented 1 year ago

Thanks a ton @MattReimer for helping @bbelletti and I through this. We got both QRiS and QRAVE going. Just to clarify, QRAVE only needed the lxml, whereas QRiS needed scipy and shapely to work for 0.1.5.

FYI @philipbaileynar

MattReimer commented 1 year ago

@joewheaton instead of having an individual checklist for each of our plugins (tedious) why not just have a "Recommended modules for Riverscapes tools" list that we maintain in one place?

Again, as far as we know this affects only OSGEO4W installs and only OSGEO4W installs that are non-default so it's a pretty thin slice.