Senc2cor UnboundLocalError: local variable 'wvcols' referenced before assignment

While running sen2cor I get an error:

Traceback (most recent call last):
  File "/opt/anaconda2/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
     self.run()
  File "/opt/anaconda2/lib/python2.7/site-packages/sen2cor-2.2.1-py2.7.egg/sen2cor/L2A_ProcessTile.py", line 129, in run
    if self.process_60() == False:
  File "/opt/anaconda2/lib/python2.7/site-packages/sen2cor-2.2.1-py2.7.egg/sen2cor/L2A_ProcessTile.py", line 154, in process_60
    return self.process()
  File "/opt/anaconda2/lib/python2.7/site-packages/sen2cor-2.2.1-py2.7.egg/sen2cor/L2A_ProcessTile.py", line 227, in process
    if(ac.process() == False):
  File "L2A_AtmCorr.py", line 3252, in L2A_AtmCorr.L2A_AtmCorr.process (L2A_AtmCorr.c:66336)
  File "L2A_AtmCorr.py", line 9828, in L2A_AtmCorr.L2A_AtmCorr.prepare_wv_retrieval (L2A_AtmCorr.c:224103)
  File "L2A_AtmCorr.py", line 9716, in L2A_AtmCorr.L2A_AtmCorr.apda1_lut_constvis_a3 (L2A_AtmCorr.c:221596)
UnboundLocalError: local variable 'wvcols' referenced before assignment

for each granule within a product.

After encountering an error sen2cor switches to processing next granule within a product but after the last granules it hangs and has to be killed manually.

Problem arises only for some products (I can provide more examples of failing or passing products).

Is there a way to fix it?

sen2cor: 2.2.1
product: S2A_OPER_PRD_MSIL1C_PDMC_20160526T200544_R050_V20160521T090903_20160521T090903.SAFE
resolution: both 20m and 60m

Same issue here with S2A_OPER_PRD_MSIL1C_PDMC_20151217T195415_R108_V20151217T103953_20151217T103953 (408fe555-175c-4760-bfd5-00374ed66200)

did you solve the problem? it seems, something related with water vapour retrieval in tiles full covered by water. Could you confirm it

I was not able to resolve it. Hopefully it will be solved in the next sen2cor version…

Python has lexical scoping by default, which means that although an enclosed scope can access values in its enclosing scope, it cannot modify them (unless they’re declared global with the global keyword). A closure binds values in the enclosing environment to names in the local environment. The local environment can then use the bound value, and even reassign that name to something else, but it can’t modify the binding in the enclosing environment. Real problem is that when python sees an assignment inside a function then it considers that variable as local variable and will not fetch its value from enclosing or global scope when we execute the function. To modify a global variable inside a function, you must use the global keyword ,otherwise it will throw an UnboundLocalError