I have written a script for automating a task on .img file. The script is running perfect on windows 7 but giving error (snapshot attached) on windows 10. Both the systems have the same version of arcmap.
<SPAN class="comment token"># -*- #################</SPAN>
<SPAN class="comment token"># ---------------------------------------------------------------------------</SPAN>
<SPAN class="comment token"># </SPAN>
<SPAN class="comment token"># </SPAN>
<SPAN class="comment token"># </SPAN>
<SPAN class="comment token"># </SPAN>
<SPAN class="comment token"># ---------------------------------------------------------------------------</SPAN>
<SPAN class="comment token"># Set the necessary product code</SPAN>
<SPAN class="keyword token">import</SPAN> arcinfo
<SPAN class="comment token"># Import arcpy module</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy<SPAN class="punctuation token">,</SPAN>os<SPAN class="punctuation token">,</SPAN>string<SPAN class="punctuation token">,</SPAN>glob<SPAN class="punctuation token">,</SPAN>sys
<SPAN class="comment token"># Script arguments</SPAN>
DEM <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#river splitted shapefiles directory path</SPAN>
rootFolder <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#output directory</SPAN>
outputDir <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Local variables:</SPAN>
home<SPAN class="operator token">=</SPAN>os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>expanduser<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'~'</SPAN><SPAN class="punctuation token">)</SPAN>
constant_raster_ <SPAN class="operator token">=</SPAN> home<SPAN class="operator token">+</SPAN><SPAN class="string token">"\\Documents\\ArcGIS\\Default2.gdb\\CreateConsta1"</SPAN>
point_feature <SPAN class="operator token">=</SPAN> home<SPAN class="operator token">+</SPAN><SPAN class="string token">"\\Documents\\ArcGIS\\Default2.gdb\\c20_FeatureVerticesToPoints"</SPAN>
point_feature_with_elevation <SPAN class="operator token">=</SPAN> point_feature
min_elevation <SPAN class="operator token">=</SPAN> home<SPAN class="operator token">+</SPAN><SPAN class="string token">"\\Documents\\ArcGIS\\Default2.gdb\\c20_FeatureVerticesToPoints_"</SPAN>
Value <SPAN class="operator token">=</SPAN> min_elevation
rastercalc <SPAN class="operator token">=</SPAN> home<SPAN class="operator token">+</SPAN><SPAN class="string token">"\\Documents\\ArcGIS\\Default2.gdb\\rastercalc"</SPAN>
WaterMask <SPAN class="operator token">=</SPAN> home<SPAN class="operator token">+</SPAN><SPAN class="string token">"\\Documents\\ArcGIS\\Default2.gdb\\Extract_rast3"</SPAN> <SPAN class="comment token"># provide a Default2 value if unspecified</SPAN>
<SPAN class="comment token">#loop for iterations through all shapefiles</SPAN>
<SPAN class="keyword token">for</SPAN> root<SPAN class="punctuation token">,</SPAN>dirs<SPAN class="punctuation token">,</SPAN>files <SPAN class="keyword token">in</SPAN> os<SPAN class="punctuation token">.</SPAN>walk<SPAN class="punctuation token">(</SPAN>rootFolder<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> name <SPAN class="keyword token">in</SPAN> files<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> name<SPAN class="punctuation token">.</SPAN>endswith<SPAN class="punctuation token">(</SPAN><SPAN class="string token">".shp"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token">#try:</SPAN>
shpName <SPAN class="operator token">=</SPAN> name <SPAN class="comment token">#os.path.splitext(name)[0] </SPAN>
<SPAN class="comment token"># absolute file path of shapefile river splits </SPAN>
absFile <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>abspath<SPAN class="punctuation token">(</SPAN>os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>rootFolder<SPAN class="punctuation token">,</SPAN>shpName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
water_body_feature_class <SPAN class="operator token">=</SPAN> absFile
<SPAN class="comment token"># Process: Create Constant Raster</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>gp<SPAN class="punctuation token">.</SPAN>CreateConstantRaster_sa<SPAN class="punctuation token">(</SPAN>constant_raster_<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"1"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"FLOAT"</SPAN><SPAN class="punctuation token">,</SPAN> DEM<SPAN class="punctuation token">,</SPAN> water_body_feature_class<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Process: Feature Vertices To Points</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>FeatureVerticesToPoints_management<SPAN class="punctuation token">(</SPAN>water_body_feature_class<SPAN class="punctuation token">,</SPAN> point_feature<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"ALL"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Process: Extract Multi Values to Points</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>gp<SPAN class="punctuation token">.</SPAN>ExtractMultiValuesToPoints_sa<SPAN class="punctuation token">(</SPAN>point_feature<SPAN class="punctuation token">,</SPAN> DEM <SPAN class="operator token">+</SPAN> <SPAN class="string token">' '</SPAN> <SPAN class="operator token">+</SPAN><SPAN class="string token">'elevation'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'NONE'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Process: Summary Statistics</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>Statistics_analysis<SPAN class="punctuation token">(</SPAN>point_feature_with_elevation<SPAN class="punctuation token">,</SPAN> min_elevation<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"elevation MIN"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Process: Get Field Value</SPAN>
<SPAN class="comment token">#arcpy.GetFieldValue_mb(min_elevation, "MIN_elevation", "Double", "0")</SPAN>
SC <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>min_elevation<SPAN class="punctuation token">)</SPAN>
field_name <SPAN class="operator token">=</SPAN> <SPAN class="string token">'MIN_elevation'</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> SC<SPAN class="punctuation token">:</SPAN>
value<SPAN class="operator token">=</SPAN>row<SPAN class="punctuation token">.</SPAN>getValue<SPAN class="punctuation token">(</SPAN>field_name<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Process: Raster Calculator</SPAN>
<SPAN class="comment token">#arcpy.gp.RasterCalculator_sa("\"%constant_raster_ %\" * float(%value%)", rastercalc)</SPAN>
<SPAN class="comment token">#arcpy.gp.RasterCalculator_sa(constant_raster_ * float(value), rastercalc)</SPAN>
rastercalc<SPAN class="operator token">=</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>sa<SPAN class="punctuation token">.</SPAN>Raster<SPAN class="punctuation token">(</SPAN>constant_raster_<SPAN class="punctuation token">)</SPAN><SPAN class="operator token">*</SPAN>float<SPAN class="punctuation token">(</SPAN>value<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Process: Extract by Mask (2) </SPAN>
WaterMask<SPAN class="operator token">=</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>gp<SPAN class="punctuation token">.</SPAN>ExtractByMask_sa<SPAN class="punctuation token">(</SPAN>rastercalc<SPAN class="punctuation token">,</SPAN> water_body_feature_class<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CopyRaster_management<SPAN class="punctuation token">(</SPAN>WaterMask<SPAN class="punctuation token">,</SPAN>outputDir<SPAN class="operator token">+</SPAN><SPAN class="string token">"\\"</SPAN><SPAN class="operator token">+</SPAN>name<SPAN class="punctuation token">.</SPAN>replace<SPAN class="punctuation token">(</SPAN><SPAN class="string token">".shp"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">''</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="operator token">+</SPAN><SPAN class="string token">".img"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#except Exception:</SPAN>
<SPAN class="comment token"># e=sys.exc_info()[1]</SPAN>
<SPAN class="comment token"># print(e.arg[0])</SPAN>
<SPAN class="comment token">#arcpy.AddError("Error in Shapefile "+shpName)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>