Skip to content

Strange error (only sometimes) in TARGET #116

@biglimp

Description

@biglimp

We are getting a strange error when students are doing the TARGET tutorial (https://umep-docs.readthedocs.io/projects/tutorial/en/latest/Tutorials/TARGETTutorial.html#targettutorial). We are trying to understand when it happens. We are running on win11, QGIS=3.44.

The following error happens when the python console is inactive (not open). If we try to run a second time, the model seem to get stuck in an infinite loop giving the log info shown at the end of this issue.

The way to get it to work is to restart QGIS, open a python console and then execute the model.

There seem to have something to do with tqdm (we think).

QGIS version: 3.44.3-Solothurn
QGIS code revision: 1d1d67e9edd
Qt version: 5.15.13
Python version: 3.12.11
GDAL version: 3.11.3
GEOS version: 3.13.1-CAPI-1.19.2
PROJ version: Rel. 9.6.2, June 4th, 2025
PDAL version: 2.9.0 (git-version: 42b180)
Algorithm started at: 2025-10-09T09:41:37
Algorithm 'Urban Heat Island: TARGET' starting…
Input parameters:
{ 'INPUT_FOLDER' : 'C:\\Users\\xlojes\\Desktop\\GE6000 Urban Climate\\TARGET\\GBGMay', 'INPUT_MET' : 'C:\\Users\\xlojes\\Desktop\\GE6000 Urban Climate\\TARGET\\GBG_torgg_3006\\ERA5_GBG_2018_UMEP.txt', 'INPUT_POLYGONLAYER' : 'C:/Users/xlojes/Desktop/GE6000 Urban Climate/TARGET/GBG_torgg_3006/gbgcity_grid_300m.shp', 'MOD_LDOWN' : False, 'OUTPUT_CSV' : False, 'OUTPUT_UMEP' : True, 'RUN_NAME' : 'gbg1', 'START_DATE' : QDate(2018, 4, 15), 'START_DATE_INTEREST' : QDate(2018, 5, 1), 'STOP_DATE_INTEREST' : QDate(2018, 6, 1) }
 
Model calculation started.
Traceback (most recent call last):
File "C:\Users/xlojes/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_umep\processor\target_algorithm.py", line 243, in processAlgorithm
tar.run_simulation(save_csv=False)
File "C:\OSGeo4W\apps\Python312\Lib\site-packages\target_py\scripts\toolkit.py", line 216, in run_simulation
for i in tqdm(range(0, len(met_data_all))):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xlojes\AppData\Roaming\Python\Python312\site-packages\tqdm\std.py", line 1098, in __init__
self.refresh(lock_args=self.lock_args)
File "C:\Users\xlojes\AppData\Roaming\Python\Python312\site-packages\tqdm\std.py", line 1347, in refresh
self.display()
File "C:\Users\xlojes\AppData\Roaming\Python\Python312\site-packages\tqdm\std.py", line 1495, in display
self.sp(self.__str__() if msg is None else msg)
File "C:\Users\xlojes\AppData\Roaming\Python\Python312\site-packages\tqdm\std.py", line 459, in print_status
fp_write('\r' + s + (' ' * max(last_len[0] - len_s, 0)))
File "C:\Users\xlojes\AppData\Roaming\Python\Python312\site-packages\tqdm\std.py", line 452, in fp_write
fp.write(str(s))
^^^^^^^^
File "C:\Users\xlojes\AppData\Roaming\Python\Python312\site-packages\tqdm\utils.py", line 140, in __getattr__
return getattr(self._wrapped, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'write'

Execution failed after 0.42 seconds
 
Loading resulting layers
Algorithm 'Urban Heat Island: TARGET' finished

This output is from the python console when trying to run the model for a second time:

--- Logging error ---

Traceback (most recent call last):

  File "C:\OSGeo4W\apps\Python312\Lib\logging\__init__.py", line 1163, in emit

    stream.write(msg + self.terminator)

    ^^^^^^^^^^^^

AttributeError: 'NoneType' object has no attribute 'write'

Call stack:

  File "C:\Users/xlojes/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_umep\processor\target_algorithm.py", line 237, in processAlgorithm

    tar.load_config()

  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\target_py\scripts\toolkit.py", line 37, in load_config

    LOG.info("loading config")

Message: 'loading config'

Arguments: ()

--- Logging error ---

Traceback (most recent call last):

  File "C:\OSGeo4W\apps\Python312\Lib\logging\__init__.py", line 1163, in emit

    stream.write(msg + self.terminator)

    ^^^^^^^^^^^^

AttributeError: 'NoneType' object has no attribute 'write'

Call stack:

  File "C:\Users/xlojes/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_umep\processor\target_algorithm.py", line 237, in processAlgorithm

    tar.load_config()

  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\target_py\scripts\toolkit.py", line 37, in load_config

    LOG.info("loading config")

Message: 'loading config'

Arguments: ()

--- Logging error ---

Traceback (most recent call last):

  File "C:\OSGeo4W\apps\Python312\Lib\logging\__init__.py", line 1163, in emit

    stream.write(msg + self.terminator)

    ^^^^^^^^^^^^

AttributeError: 'NoneType' object has no attribute 'write'

Call stack:

  File "C:\Users/xlojes/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_umep\processor\target_algorithm.py", line 243, in processAlgorithm

    tar.run_simulation(save_csv=False)

  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\target_py\scripts\toolkit.py", line 98, in run_simulation

    LOG.info("running simulation")

Message: 'running simulation'

Arguments: ()

--- Logging error ---

Traceback (most recent call last):

  File "C:\OSGeo4W\apps\Python312\Lib\logging\__init__.py", line 1163, in emit

    stream.write(msg + self.terminator)

    ^^^^^^^^^^^^

AttributeError: 'NoneType' object has no attribute 'write'

Call stack:

  File "C:\Users/xlojes/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_umep\processor\target_algorithm.py", line 243, in processAlgorithm

    tar.run_simulation(save_csv=False)

  File "C:\OSGeo4W\apps\Python312\Lib\site-packages\target_py\scripts\toolkit.py", line 98, in run_simulation

    LOG.info("running simulation")

Message: 'running simulation'

Arguments: ()

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions