I am trying to write a very simple script that exports a layer to KMZ file using LayerToKML GP tool.
<SPAN class="keyword token">import</SPAN> arcpy
out<SPAN class="operator token">=</SPAN>r<SPAN class="string token">"C:\AhmadData\di\pro\test.kmz"</SPAN>
pLocation<SPAN class="operator token">=</SPAN>r<SPAN class="string token">"C:\AhmadData\di\pro\data5\Data5.aprx"</SPAN>
p <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mp<SPAN class="punctuation token">.</SPAN>ArcGISProject<SPAN class="punctuation token">(</SPAN>pLocation<SPAN class="punctuation token">)</SPAN>
mp <SPAN class="operator token">=</SPAN> p<SPAN class="punctuation token">.</SPAN>listMaps<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">for</SPAN> lyr <SPAN class="keyword token">in</SPAN> mp<SPAN class="punctuation token">.</SPAN>listLayers<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN>lyr<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>conversion<SPAN class="punctuation token">.</SPAN>LayerToKML<SPAN class="punctuation token">(</SPAN>lyr<SPAN class="punctuation token">,</SPAN>out<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"NO_COMPOSITE"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"DEFAULT"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">1024</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">96</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"CLAMPED_TO_GROUND"</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>the Data source is file FGDB and Pro map has only one layer with 10 lines features ( the data is very simple)
the script executed locally on my C drive, but I keep getting this error
arcgisscripting.ExecuteError: ERROR 000210: Cannot create output C:\Users\<USER>\AppData\Local\Temp\{74AB2B10-C6A1-4D89-AB64-FE6CE55D17FE}.lyrx
Failed to execute (LayerToKML).
I checked my local temp folder and I have full Read and Write permissions. my question is why I am getting this error, and why the tool is trying to export the lyrx to the temp folder?
I tired to set arcpy.env.workspace to point to the project location but it didnt nothing.
I am using ArcGIS Pro 2.5
Thanks