[QGIS-Developer] free variable 'self' referenced before assignment in enclosing scope

Bjørn Burr Nyberg Bjorn.Nyberg at uib.no
Wed Jan 30 08:40:11 PST 2019


Dear QGIS community,

In the spirit of open-source I am trying to convert a set of scripts that ive designed in ArcMap to QGIS 3.x. I hope that this will enable a broader community of individuals to use the workflows ive designed. The original scripts can be found at https://github.com/BjornNyberg/NetworkGT/tree/master/Scripts

My problem is that in my first attempt to convert the scripts, QGIS either crashes or gives the following error. 

2019-01-30T16:51:27     WARNING    Traceback (most recent call last):
              File "C:/PROGRA~1/QGIS3~1.4/apps/qgis/./python/plugins\processing\gui\AlgorithmDialog.py", line 238, in on_complete
              self.feedback.pushInfo(self.tr('Execution completed in {0:0.2f} seconds').format(time.time() - start_time))
             NameError: free variable 'self' referenced before assignment in enclosing scope

I have established that this error occurs at the very end of the script when calling ' return {self.Branches:dest_id,self.Nodes:dest_id2}'. I do not believe that I have explicitly defined self  anywhere in the processAlgorithm function itself. The algorithms themselves work as intended and the shapefiles are created before the program crashes. 

I am not a programmer by trait so I'm not entirely sure how to problem solve this error and any help would be most appreciated. I can also provide a test dataset if that is helpful. 

Cheers,
Bjorn
-----------------------------
Postdoctoral Fellow
Department of Earth Science, University of Bergen              
PO Box 7803, 5020, Bergen, Norway
+47 485 024 08

 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.py
Type: application/octet-stream
Size: 13958 bytes
Desc: test2.py
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190130/a1807968/attachment-0001.obj>


More information about the QGIS-Developer mailing list