I'm new with ArcGIS. I would like to do a calculate of NDWI. So I'm using Arctoolbox => Spatial analyst tools => Map Algebra => Raster calculator.

But when I'm trying to perform it, I get this error :

Executing: RasterCalculator "Float("LT05_L1TP_196030_19990113_20180215_01_T1_sr_band2.tif" - "LT05_L1TP_196030_19990113_20180215_01_T1_sr_band5.tif") / Float("LT05_L1TP_196030_19990113_20180215_01_T1_sr_band2.tif" + "LT05_L1TP_196030_19990113_20180215_01_T1_sr_band5.tif")" D:\Users\paulc\Documents\SIG_ZHM\NDWI\1999_01_13_NDWI.tif
Start Time: Thu Oct 24 15:42:34 2019
Float(Raster(r"LT05_L1TP_196030_19990113_20180215_01_T1_sr_band2.tif") - Raster(r"LT05_L1TP_196030_19990113_20180215_01_T1_sr_band5.tif")) / Float(Raster(r"LT05_L1TP_196030_19990113_20180215_01_T1_sr_band2.tif") + Raster(r"LT05_L1TP_196030_19990113_20180215_01_T1_sr_band5.tif"))

ERROR 000539: Error running expression: rcexec() 
Traceback (most recent call last):
  File "<expression>", line 1, in <module>
  File "<string>", line 2, in rcexec
  File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\__init__.py", line 21, in <module>
    from arcpy.geoprocessing import gp
  File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
    from _base import *
  File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\geoprocessing\_base.py", line 598, in <module>
    env = GPEnvironments(gp)
  File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\geoprocessing\_base.py", line 595, in GPEnvironments
    return GPEnvironment(geoprocessor)
  File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\geoprocessing\_base.py", line 548, in __init__
    import weakref
  File "D:\Programmes (x86)\Python\Lib\weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref

Failed to execute (RasterCalculator).

How can I fix this?

I have already tried to change the wayfolder for a shorter way, without space or special character, but it's still like there is a problem with the wayfolder.

  • Just tried your logic and it worked for me. Have you seen this and may be this?
    – Hornbydd
    Commented Oct 24, 2019 at 14:08
  • ok just to be sure, i need to do a python script, and open it in argis to run it ? i'm a student, so i'm a bit stuck with the comprehension of this. Thank you for your answear Commented Oct 24, 2019 at 18:10
  • 1
    I suspect the problem lies elsewhere, your equation is quite simple and should not be throwing an error. May be you have a corrupted install of ArcMap? May be there are network issues with your source datasets?
    – Hornbydd
    Commented Oct 24, 2019 at 21:56

1 Answer 1


Rename the bands for the ndwi. say band 1, band2, band3, and band 4. Open python IDE in ArcMap, and type in * img 1 = arcpy.Raster("C:/band1(Path)") - Do for img 2, img 3 and img 4 * Ndwi =float( img 1 - img2)/ img 1 + img 2

This can be an alternative to raster calculator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.