Python errors when trying to use QSWAT+ plugin

703 views
Skip to first unread message

Heather Moule

unread,
Sep 5, 2023, 4:53:50 PM9/5/23
to QSWAT+
Hi all, 

I have been having issues getting started. I believe I have successfully converted my arcSWAT project to SWAT+. I originally thought I was having the error due to something related to the conversion, but even when I try and start a new project I get the same error. 

I am using QGIS 3.28.10 and QSWAT+ version 2.4.2 on Windows (Although it is still indicating it as 2.4.1). 

I have included screenshots (attached) for error logs in both the python error box and QSWAT+ box. 

Thanks,

Heather
qswat_pythonerror.PNG
qswat_pythonerror2.PNG

Moule, Heather A

unread,
Sep 6, 2023, 8:55:53 AM9/6/23
to Chris George, QSWAT+
Thanks Chris, 

Can you please send me it with either a different extension or as a zip? Py files always get blocked for us 😕


Heather Moule (she/her) 
Hydrologist

U.S. Geological Survey
New York Water Science Center


 

       

From: Chris George <cge...@tamu.edu>
Sent: Wednesday, September 6, 2023 6:22 AM
To: Moule, Heather A <hmo...@usgs.gov>; QSWAT+ <qswa...@googlegroups.com>
Subject: [EXTERNAL] Re: [QSWAT+ User Group] Python errors when trying to use QSWAT+ plugin
 


 This email has been received from outside of DOI - Use caution before clicking on links, opening attachments, or responding.



Hi Heather,

Sorry about this. you need to replace gwflow.py with the attached.  You
will find gwflow.py in

C:\Users\<username>\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\QSWATPlus3_9\QSWATPlus


if you installed just for yourself, else in

C:\Program Files\<QGIS>\apps\qgis-ltr\python\plugins\QSWATPlus3_9\QSWATPlus

Chris


On 9/5/2023 9:53 PM, 'Heather Moule' via QSWAT+ wrote:
> Hi all,  I have been having issues getting started. I believe I have
> successfully converted my arcSWAT project to SWAT+. I originally thought
> I was having the error due to something related to the conversion, but
> even when I try and start a
> ZjQcmQRYFpfptBannerStart
> This Message Is From an External Sender
> This message came from outside your organization.
> ZjQcmQRYFpfptBannerEnd
> --
> You received this message because you are subscribed to the Google
> Groups "QSWAT+" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to qswatplus+...@googlegroups.com
> <mailto:qswatplus+...@googlegroups.com>.
> To view this discussion on the web visit
> https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fqswatplus%2F9321ac7e-35a9-45d8-b190-5799d5c1d619n%2540googlegroups.com&data=05%7C01%7Chmoule%40usgs.gov%7C43b652979ff849cf3bb908dbaec32281%7C0693b5ba4b184d7b9341f32f400a5494%7C0%7C0%7C638295925360508695%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=jNRuSLB4v%2F1K6F3U9PWOmKSKKYZIGMRDATNGKt%2F1Rfs%3D&reserved=0 <https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fqswatplus%2F9321ac7e-35a9-45d8-b190-5799d5c1d619n*40googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter__%3BJQ!!KwNVnqRv!AFxVRTmiHzffMTfV-iTE7ZoH1DC905dO2oPONAScTb6WNBZTrvYwXaP4vBxGHbPvg5KrwlJ8EAXzkRFG3Gu9WhA%24&data=05%7C01%7Chmoule%40usgs.gov%7C43b652979ff849cf3bb908dbaec32281%7C0693b5ba4b184d7b9341f32f400a5494%7C0%7C0%7C638295925360664922%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=nwLwMXCyBItGbwJObxMb2UJB1dFDsO3K7QFLt%2FXJeVQ%3D&reserved=0>.

Chris George

unread,
Sep 6, 2023, 12:37:10 PM9/6/23
to QSWAT+
Please install the latest version of QSWAT+, version 2.4.5, which is available today on the SWAT website.

Thanks,
Chris

Aggeliki Mentzafou

unread,
Sep 7, 2023, 7:33:52 AM9/7/23
to QSWAT+
Hello.

I am experiencing the following problem.
In order to update to the most recent QSWAT+ version, I uninstalled everything except QGIS and install the new downloaded executable files.
Now I get the following python error when opening the tool:

An error has occurred while executing Python code:

NameError: name 'GlobalVars' is not defined
Traceback (most recent call last):
  File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python/plugins\QSWATPlus3_9\QSWATPlus\QSWATPlusMain.py", line 212, in run
    self.setupProject(proj, False)
  File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python/plugins\QSWATPlus3_9\QSWATPlus\QSWATPlusMain.py", line 342, in setupProject
    self._gv = GlobalVars(self._iface, QSWATPlus.__version__, self.plugin_dir, isBatch, isHUC, logFile)
NameError: name 'GlobalVars' is not defined


Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]
QGIS version: 3.22.11-Białowieża Białowieża, 106d33d7

Python Path:
C:/PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python
C:/Users/ang_m/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/ang_m/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python/plugins
C:\PROGRA~1\QGIS 3.22.11\bin\python39.zip
C:\PROGRA~1\QGIS 3.22.11\apps\Python39\DLLs
C:\PROGRA~1\QGIS 3.22.11\apps\Python39\lib
C:\PROGRA~1\QGIS 3.22.11\bin
C:\PROGRA~1\QGIS 3.22.11\apps\Python39
C:\PROGRA~1\QGIS 3.22.11\apps\Python39\lib\site-packages
C:\PROGRA~1\QGIS 3.22.11\apps\Python39\lib\site-packages\win32
C:\PROGRA~1\QGIS 3.22.11\apps\Python39\lib\site-packages\win32\lib
C:\PROGRA~1\QGIS 3.22.11\apps\Python39\lib\site-packages\Pythonwin
C:/Users/ang_m/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python/plugins\QSWATPlus3_9\QSWATPlus


2023-09-07T07:33:48     INFO    QSWAT+ failed to import HRUs: Traceback (most recent call last):
              File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python/plugins\QSWATPlus3_9\QSWATPlus\QSWATPlusMain.py", line 55, in
              from .hrus import HRUs
              File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import
              mod = _builtin_import(name, globals, locals, fromlist, level)
              File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python/plugins\QSWATPlus3_9\QSWATPlus\hrus.py", line 57, in
              from .gwflow import GWFlow # type: ignore
              File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import
              mod = _builtin_import(name, globals, locals, fromlist, level)
              File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python/plugins\QSWATPlus3_9\QSWATPlus\gwflow.py", line 36, in
              import geopandas as gpd
              File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import
              mod = _builtin_import(name, globals, locals, fromlist, level)
             ModuleNotFoundError: No module named 'geopandas'

2023-09-07T07:34:18     WARNING    Traceback (most recent call last):
              File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python/plugins\QSWATPlus3_9\QSWATPlus\QSWATPlusMain.py", line 212, in run
              self.setupProject(proj, False)
              File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python/plugins\QSWATPlus3_9\QSWATPlus\QSWATPlusMain.py", line 342, in setupProject
              self._gv = GlobalVars(self._iface, QSWATPlus.__version__, self.plugin_dir, isBatch, isHUC, logFile)
             NameError: name 'GlobalVars' is not defined
             
2023-09-07T07:35:08     WARNING    Traceback (most recent call last):
              File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python/plugins\QSWATPlus3_9\QSWATPlus\QSWATPlusMain.py", line 212, in run
              self.setupProject(proj, False)
              File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python/plugins\QSWATPlus3_9\QSWATPlus\QSWATPlusMain.py", line 342, in setupProject
              self._gv = GlobalVars(self._iface, QSWATPlus.__version__, self.plugin_dir, isBatch, isHUC, logFile)
             NameError: name 'GlobalVars' is not defined
             
2023-09-07T07:35:14     WARNING    Traceback (most recent call last):
              File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python/plugins\QSWATPlus3_9\QSWATPlus\QSWATPlusMain.py", line 212, in run
              self.setupProject(proj, False)
              File "C:\PROGRA~1/QGIS 3.22.11/apps/qgis-ltr/./python/plugins\QSWATPlus3_9\QSWATPlus\QSWATPlusMain.py", line 342, in setupProject
              self._gv = GlobalVars(self._iface, QSWATPlus.__version__, self.plugin_dir, isBatch, isHUC, logFile)
             NameError: name 'GlobalVars' is not defined

Is there a solution for this error?
I also tried installing the most recent QSWAT+ version with the latest stable QGIS version 3.28 as recommended, but in this case the QSWAT+ plugin did not appear into the QGIS toolbar.

Thank you in advance
Angeliki

Chris George

unread,
Sep 7, 2023, 7:36:09 AM9/7/23
to QSWAT+
Sorry about this.  Fixed in QSWAT+ 2.4.6 from https://bitbucket.org/christophergeorge/qswatplus3/downloads/.  You are also now recommended to use QGIS 3.22.

Samanta Tolentino Cecconello

unread,
Sep 17, 2023, 8:08:15 AM9/17/23
to QSWAT+
Hello Chris George
I'm also having problems with python in QGis when trying to create landscape. I was using version 3.22 of Qgis and 2.4.6 in SWAT+ and I tried to run it with Qgis 3.28 and the same error appeared. I reinstalled SWAT+ and Qgis several times to see if it fixed it, but nothing. There are times when errors appear with Taudem too.
Below is the error message that appears in the QSWAT+ tab.
Thank you.
error python SWAT2.4.6.txt

Samanta Tolentino Cecconello

unread,
Sep 17, 2023, 8:08:15 AM9/17/23
to QSWAT+
Hi Chris George,
I tried to do everything as indicated here in the group. I installed QGIS 3.22.12 and the new version in SWAT+, but the error in Python remains the same. I tested it with QGIS 3.28 too and it doesn't work. I'm using Win 11.

Em quinta-feira, 7 de setembro de 2023 às 08:36:09 UTC-3, Chris George escreveu:
Reply all
Reply to author
Forward
0 new messages