I’m not familiar with sen2cor but I think you can just enter the path to the python.exe.
I had the same issue. First I could not enter the python path. But after double clicking on one of the other variables it became also “activated” for the PYTHON_BIN.
Maybe it is the same issue for you.
Thank you marpet and abgbaumann.
After double clicking in the cell and entering the path “C:\Anaconda2\python.exe” as value for the PYTHON_BIN it doesn’t persist in the cell (it disappears when I leave it and cannot be saved. It seems this is a bug in SNAP 3 since a system variable value cannot be saved.
I finally I found a turnaround solution that works: I uncheck (red cross on the left) the system variable PYTHON_BIN which then disappears. Then I re-entered it (PYTHON_BIN) and entered its value (“C:\Anaconda2\python.exe”) and clicked OK and it was saved. Now sen2cor works.
I hope this can be of use to some sen2cor users.
Unfortunately I have noticed that after closing and reopening SNAP 3, the same problem occurs again and I have to do the procedure above again.
It seems there’s problem with the storing of edited system variables!
Given the problems I have with sen2cor plugin, I have continued to search for the problems that prevent setting in a stable manner the value of the system variable PYTHON_BIN.
Normally the value of the system variable PYTHON_BIN is python.exe. However the plugin needs to find this executable in the folder where it is located. I think the pointer to the folder that contains the python executable is to be provided under Configuration parameters/Tool location ($PYTHON_BIN). The tool location should obviously be a folder.
However, when I click the browse button (…) in front of Tool location, a file browser and not a folder browser appears. Therefore it is impossible for me to indicate C:\Anaconda2 as a location.
Sen2cor PHYTON_BIN_Ghanisen.pdf (69.2 KB)
My current turnaround is to enter the value C:\Anaconda2\python.exe for PYTHON_BIN that is I include the path with the executable name. Sen2cor does then work for the current SNAP session but since the path of PHYTON_BIN is not stored, the procedure has to be repeated each time the tool is used.
Therefore the main problem seems to be that the tool location (Folder where python.exe is located) cannot be entered and stored.
I hope this can be checked and eventually corrected by those who designed the sen2cor plugin which is so useful and indispensible to those who use sentinel2 imagery.
I have also mentioned in another post that when using sen2corr to process sentinel2 L1C images, only the first granule is processed.
I am experiencing similar problems, except when I set the value of PYTHON_BIN using Ghanisen’s work around to C:…\Anaconda2\python.exe and click OK my environment settings are accepted, but when I try to run Sen2Cor I get an error telling me that PYTHON_BIN is not set. @Ghanisen Are there any other steps that weren’t detailed that allowed you to execute Sen2Cor successfully?
I have found another way to solve this PYTHON_BIN environment variable in a durable way (Please note that I work with Windows 10 but the procedure should be the same for Windows 7):
- After installing Anaconda2, go to your Windows in your computer and search for Modify environment variables. You will end up with a screen like this:
Click Environment variables and this will open the next screen:
Click New under the upper window and then you add a new variable PYTHON_BIN and give it a value C:\Users<user>\Anaconda2 as highlighted in red in the same window (user is Ghani for me). Now the path of the PYTHON_BIN shall persist thus allowing you to run sen2cor.
Return to SNAP and open Tools/Manage External. This will bring you to the following screen:
Select Sen2cor and click Edit. This shall open the next screen:
You see that now PYTHON_BIN path is there. We now have to select the values of the 2 parameters under Configuration Parameters. Please note that the help on this screen does not give any explanation on what is to be selected for the Tool location there but since $PYTHON_BIN is indicated in front of tool location I opted to point to the python executable . However they give clear indications about the working directory SENCOR_Home.
For the Tool location, click the … indicated by the red arrow and go to the python.exe file in your Anaconda2 directory (for me C:\Users\Ghani\Anaconda2\python.exe) select it and click ok.
Now you will be able to run sen2cor.
However, as it was brilliantly shown by @ChristianSeverin in this forum, a problem exists with the file L2A_Tables.py, which does the conversion from L1C to L2A, and he offered a solution on which I am going to comment right now in a new topic.
@Ghanisen thank you for your well described solution.
I wonder if you could help.
I am struggling with the SEN2COR_BIN value. Actually, I was struggling on finding its directory, so I tried to do as you suggeste here.
The problem is that I clueless about to type in the value.
So for now it is looking like this:
Thank you in advance!!
There seem to be a problem with your SEN2COR_BIN variable. Therefore please check if you have a sen2cor folder at c:\Users\sara aparicio\AppData\Local\Anaconda2\Lib\site-packages\sen2cor. If it is, then this gives you the string value you should enter. Otherwise search where is your sen2cor folder inside Anaconda2 folder.
Thank you for your quick response @Ghanisen.
I found this, but in a slightly different location (highlighted in red):
Would you recoomend me to change it directly on SNAP ? or change it first at the "Modify Environment System
Yes, try first in SNAP and if it doesn’t work, then in the “Modify Environment System variables”.
can you try typing
L2A_Process in your command line and see what happens?
The question raised by @ABraun is pertinent because if it works that would mean that sen2cor was correctly installed. If not, it is perhaps better to uninstall sen2cor and re-install it again.
Sorry; it is very difficult to give advice not knowing what you have done exactly.
that is basically good. It means that sen2cor works on your PC
the only thing which is missing yet is the SNAP integration. So you either have to find the correct path for your folders.
Where is your Anaconda installation? For me it is this, for example:
And I wonder why it is under AppData\Local in your case.
What happens if you simply type
python in your command line?
that’s also good.
Try replacing the
PYTHON_BIN in SNAP (manage external tools) with
instead of just python.exe
and then try to run it again in SNAP.
I suggest you go inside SNAP/ Tools/Manage External Tools the select sen2cor and click edit.
In the screen that would appear 2 items need your attention 1) Configuration Parameters and 2) System Variables.
I have attached sceenshots for what should be there (adapt to your computer). Please note that for $PYTHON_BIN you have to navigate (click …) to the python2.7 under your Anaconda2 directory.
If this doesn’t work I would advice to remove sen2cor and re-install it again.
I changed to that, but strangely it seems that it doesn’t get updated.
I close and opened again the manager tool, and if I got to the value, it what I wrote, but not on the system variables display:
It is not on the System variables screen that you set the path to the python executable, it is in the Configuration Parameters screen as I showed in my previous comment.
The python executable, for me python2.7 is in the bin folder under the Anaconda2 directory. Please follow the indications in my previous comment.
One last thing; what operating system are you using?