How to add raster dataset to active map contents using arcPy in ArcGIS Pro? The code below gives me an error on line 10, "ValueError: tempRas". I am trying to migrate ArcMap 10.5 to ArcGIS Pro and I am having difficulty finding a solution for this problem. I would very much appreciate your help.
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">import</SPAN> traceback
<SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN>
aprx <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mp<SPAN class="punctuation token">.</SPAN>ArcGISProject<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'CURRENT'</SPAN><SPAN class="punctuation token">)</SPAN>
ras <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<path to>\\example.tif'</SPAN>
rasTempLyr <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>MakeRasterLayer_management<SPAN class="punctuation token">(</SPAN>ras<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'tempRas'</SPAN><SPAN class="punctuation token">)</SPAN>
activeMap <SPAN class="operator token">=</SPAN> aprx<SPAN class="punctuation token">.</SPAN>activeMap
activeMap<SPAN class="punctuation token">.</SPAN>addLayer<SPAN class="punctuation token">(</SPAN>rasTempLyr<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'TOP'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">except</SPAN><SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddError<SPAN class="punctuation token">(</SPAN>traceback<SPAN class="punctuation token">.</SPAN>format_exc<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</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>