Sen2Cor 2.2.1 Error

Dear All,

I have managed to successfully install the Sen2Cor 2.2.1 version. I tried processing the data from USGS earth explorer website and am getting the below error

Kindly help

Sentinel-2 Level 2A Prototype Processor (Sen2Cor), 2.2.1, created: 2016.04.29 started …
Traceback (most recent call last):
File “C:\Anaconda2\Scripts\”, line 9, in
load_entry_point(‘sen2cor==2.2.1’, ‘console_scripts’, ‘L2A_Process’)()
File “C:\Anaconda2\lib\site-packages\sen2cor-2.2.1-py2.7.egg\sen2cor\”, line 228, in main
L2A_TILES = updateTiles(config)
File “C:\Anaconda2\lib\site-packages\sen2cor-2.2.1-py2.7.egg\sen2cor\”, line 42, in updateTiles
L2A_TILE_ID = config.create_L2A_Tile(tile)
File “C:\Anaconda2\lib\site-packages\sen2cor-2.2.1-py2.7.egg\sen2cor\”, line 3129, in create_L2A_Tile
L2A_TILE_MTD_XML = filename
UnboundLocalError: local variable ‘filename’ referenced before assignment

I guess that you have already an existing (corrupt) L2A Product of the same name which origins from a previous processing. Remove this and start from schratch …

Confirming the same error message here. There is no L2A product from previous processing in the specified target directory. Waht do you mean by start from scratch?

From sen2cor log file i get the follwoing information:

cannot create the config object configPic.p


I am facing the same problem from a linux machine. Is there any solution known, or what causes this problem?

I have tried deleting all created S2A_USER folders and after launching the reprocessing the same error occurs again.
I am trying to process individual granules. This worked for some dates but not for all.

I am facing the same problem now… I am processing the L1C products granule-wise and it was working for some time now… However, this problem usually only appears with the first granule that needs to be really does not matter, which granule it is… only that is the first one…Does anyone know where this issue originates from?

EDIT: If you are working locally, always store your data on the shortest possible pathes! :wink:
I was previously working on a path with spaces, which probably caused the problems. After changing the directory to a sub folder of C:\ it works just fine!

I have a similar problem with sen2cor 2.2.1 under Linux. it seems to work from the SNAP GUI but when I run from command line I get the following error:
File "/home/goldie/anaconda2/lib/python2.7/site-packages/sen2cor-2.2.1-py2.7.egg/sen2cor/", line 46, in __init__ stderrWrite('Cannot load configuration\n.' % picFn) TypeError: not all arguments converted during string formatting

Any advice on how to solve it?

And the same here. It’s difficult to believe no one has found a solution.

I had the same error, but for some reason my user profile did not have full admin privileges , try to run CMD as Admin and then set off the L2A_Process code.



Could it have something to do with where the file has been downloaded from? I have had little difficulty with Sentinel files from the ESA website, and tried processing my first Earth Explorer Sentinel file, and had the same problem as above.

  File "/Applications/anaconda/bin/L2A_Process", line 9, in <module>
load_entry_point('sen2cor==2.3.0', 'console_scripts', 'L2A_Process')()
  File "/Applications/anaconda/lib/python2.7/site-packages/sen2cor-2.3.0-py2.7.egg/sen2cor/", line 169, in main
  File "/Applications/anaconda/lib/python2.7/site-packages/sen2cor-2.3.0-py2.7.egg/sen2cor/", line 3072, in setSchemes
self.logger.fatal('wrong identifier for xml structure: ' + product)
AttributeError: 'NoneType' object has no attribute 'fatal'

I noticed as well that the folder name changed slightly. (could this have something to do with it?)



please specify exactly the URL where you downloaded the file and the name of the product you try to process. Otherwise I cannot start to reproduce your problem.

I have processed all night and then this morning I tried to process a new tile and got the error

L2A_Process media/julien/NuDrive1/WorkInProcess/Chris/Latitude_hill/S2A_MSIL1C_20170731T012721_N0205_R131_T52JDR_20170731T013300.SAFE/
Sentinel-2 Level 2A Processor (Sen2Cor), 2.4.0, created: 2017.06.05 started …
Cannot create the config object configPic.p, parent folder may be write protected.

I have checked, there is nothing strange on rights in either the script or the destination. I am admin but I am reluctant in firing a script as a super user. So was a bit stuck.

My hack was that I went into the destination folder and ran the command and this worked

/media/julien/NuDrive1/WorkInProcess/Chris/Latitude_hill$ L2A_Process S2A_MSIL1C_20170731T012721_N0205_R131_T52JDR_20170731T013300.SAFE/

This is strange, is it the way the paths are called? Of course the root ‘/media’ is not accessible, it is the same error like if the script tried to write there.

So the command needs to be started from the folder containing the data folder (at least in my case).

Hope this help.

I have run into this issue recently. And it seems to be more frequent when I have many subprocesses (>=3) starting the L2A_Process at the same time, it seems one sometimes cannot get the lock on the parent folder and has the “cannot create the config object configPic.p” error. For me the solution will be to delete the leftover L2A folder when the error occurs and retry. It isn’t a solution but I just wanted to say for me I have a hunch it is related to having subprocesses or threads calling L2A_Process and causing a locking issue on the container directory.

1 Like