Bug report #17192

Python error in Processing/QGIS clip

Added by Giovanni Manghi over 6 years ago. Updated over 6 years ago.

Status:Closed
Priority:High
Assignee:Victor Olaya
Category:Processing/QGIS
Affected QGIS version:2.18.13 Regression?:Yes
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:25091

Description

This is kind of weird error because it does not show in all installations and does not depends on the operating system (seen on Windows and as well on Linux). It has also been observed in completely clean systems and installations, possibly excluding local issues.

The error is

2017-09-24T11:10:53 2 Uncaught error while executing algorithm
Traceback (most recent call last):
File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\core\GeoAlgorithm.py", line 203, in execute
self.processAlgorithm(progress)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\algs\qgis\Clip.py", line 99, in processAlgorithm
total = 100.0 / len(features) if len(features) > 0 else 1
NameError: global name 'features' is not defined

and with the same test dataset (attached) does not show in 2.14

https://www.dropbox.com/s/gitlghh1r2omkwy/clip_error.zip?dl=0


Related issues

Duplicated by QGIS Application - Bug report #17248: Can't clip a vector polygon in qgis 2.18.19 Closed 2017-10-05

History

#1 Updated by Claas Leiner over 6 years ago

I have observed the same error. With different data and with different installations under Linux Ubuntu 16.04 with ubuntugis dependencies. In previous 2.18 releases, the error did not occur! I do not know, in which 2.18.x it still worked.

error messages

2017-09-26T22:58:22 2 Fehler in Algorithmusausführung Clip
global name 'features' is not defined
See log for more details
2017-09-26T22:58:55 2 Uncaught error while executing algorithm
Traceback (most recent call last):
File "/usr/share/qgis/python/plugins/processing/core/GeoAlgorithm.py", line 203, in execute
self.processAlgorithm(progress)
File "/usr/share/qgis/python/plugins/processing/algs/qgis/Clip.py", line 99, in processAlgorithm
total = 100.0 / len(features) if len(features) > 0 else 1
NameError: global name 'features' is not defined

2017-09-26T22:58:55 2 Fehler in Algorithmusausführung Clip
global name 'features' is not defined
See log for more details
2017-09-26T23:02:01 2 Uncaught error while executing algorithm
Traceback (most recent call last):
File "/usr/share/qgis/python/plugins/processing/core/GeoAlgorithm.py", line 203, in execute
self.processAlgorithm(progress)
File "/usr/share/qgis/python/plugins/processing/algs/qgis/Clip.py", line 99, in processAlgorithm
total = 100.0 / len(features) if len(features) > 0 else 1
NameError: global name 'features' is not defined

2017-09-26T23:02:01 2 Fehler in Algorithmusausführung Clip
global name 'features' is not defined
See log for more details

#2 Updated by Claas Leiner over 6 years ago

In a QGIS-Installation from May 2017 in the
clip.py I find in Line 98 - 101

if single_clip_feature:
total = 100.0 / len(input_features)
else:
total = 0

In this time Clip runs korrekt.

-------
-----
In qgis 2.18.13 Line 08 - 101:

if single_clip_feature:
total = 100.0 / len(features) if len(features) > 0 else 1
else:
total = 0
clip don't run

#3 Updated by Alexander Bruy over 6 years ago

  • Resolution set to fixed/implemented
  • Status changed from Open to Closed

#4 Updated by Ben Wirf over 6 years ago

I am still getting this global name 'features' is not defined error message when trying to run the QGIS clip tool in QGIS 2.18.13 on Windows 8.1 machine. I have re-run the OSGEO4W installer (custom install), and selected reinstall 2.18.13. Deleted QGIS2 folder and restarted. The problem still persists.

#5 Updated by Giovanni Manghi over 6 years ago

Ben Wirf wrote:

I am still getting this global name 'features' is not defined error message when trying to run the QGIS clip tool in QGIS 2.18.13 on Windows 8.1 machine. I have re-run the OSGEO4W installer (custom install), and selected reinstall 2.18.13. Deleted QGIS2 folder and restarted. The problem still persists.

the patch is not in 2.18.13, will be in .14

#6 Updated by Ben Wirf over 6 years ago

No problem. Thanks Giovanni.

#7 Updated by Jürgen Fischer over 6 years ago

Also available in: Atom PDF