<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Geoprocessing Script Tool Fails - scratchWorkspace tool or environment not found in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/geoprocessing-script-tool-fails-scratchworkspace/m-p/398460#M15478</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a python script which when run in ArcMap works perfectly....&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When creating the script tool in ArcMap, "Always run in foreground" is unchecked, "store relative path names" is checked, and "run python script in process" is checked.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However, when I publish this script to an ArcGIS for Server 10.1 SP1 installation, executing the GPService fails with the following error from the logs: &lt;/SPAN&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "E:\arcgisserver\directories\arcgissystem\arcgisinput\EON\AirportsExportPython.GPServer\extracted\v101\toolboxes\AirportsExport.py", line 38, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outputFclass = arcpy.env.scratchWorkspace+"\\clipped.shp"&lt;BR /&gt;&amp;nbsp; File "c:\program files\arcgis\server\arcpy\arcpy\geoprocessing\_base.py", line 525, in get_&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return self[env]&lt;BR /&gt;&amp;nbsp; File "c:\program files\arcgis\server\arcpy\arcpy\geoprocessing\_base.py", line 575, in __getitem__&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return convertArcObjectToPythonObject(getattr(self._gp, item))&lt;BR /&gt;AttributeError: Object: Tool or environment &amp;lt;scratchWorkspace&amp;gt; not found&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the script: &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, csv, os arcpy.env.overwriteOutput = True&amp;nbsp; # Script arguments Selecting_Geometry = arcpy.GetParameterAsText(0) if Selecting_Geometry == '#' or not Selecting_Geometry: &amp;nbsp;&amp;nbsp;&amp;nbsp; Selecting_Geometry = r"E:\EON\data\templates.gdb\polygonTemplate"&amp;nbsp;&amp;nbsp; OutputType = arcpy.GetParameterAsText(1) if OutputType == '#' or not OutputType: &amp;nbsp;&amp;nbsp;&amp;nbsp; OutputType = "kmz"&amp;nbsp;&amp;nbsp; # Local variables: arcpy.env.scratchWorkspace = r"E:\EON\temp" outputFclass = arcpy.env.scratchWorkspace+"\\clipped.shp" AirportsLayer = r"E:\EON\layers\LandingFacilitiesOrganized.lyr" Airports = r"E:\EON\data\FAA.gdb\airports" exportLayer = arcpy.env.scratchWorkspace+"\\exportLayer.lyr"&amp;nbsp; # Process: Clip arcpy.Clip_analysis(Airports, Selecting_Geometry, outputFclass, "") OutputFile = arcpy.env.scratchWorkspace+"\\airportsExportResult.kmz" earthLayer = arcpy.mapping.Layer(AirportsLayer) for layer in earthLayer: &amp;nbsp;&amp;nbsp;&amp;nbsp; if layer.isGroupLayer: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue &amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.replaceDataSource(arcpy.env.scratchWorkspace, "SHAPEFILE_WORKSPACE", "clipped") earthLayer.saveACopy(exportLayer) arcpy.LayerToKML_conversion(exportLayer, OutputFile, "1", "false", exportLayer, "1024", "96", "CLAMPED_TO_GROUND") arcpy.SetParameterAsText(2,OutputFile) &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In short, this script clips a feature set to an input polygon, applies a complicated layer file to it, then exports to kmz.&amp;nbsp; I got this geoprocessing tool working correctly earlier, but was using arcpy.env.workspace instead of arcpy.env.scratchWorkspace, so the process wasn't referencing the clipped file in a jobs directory, but instead in the hardcoded workspace directory in the script.&amp;nbsp; Anyway, after some research I saw that I have to use scratchWorkspace for all intermediate data.&amp;nbsp; But this broke the geoprocessing service.&amp;nbsp; Any assistance would be greatly appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, Jay&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Dec 2012 19:02:43 GMT</pubDate>
    <dc:creator>Jay_Gregory</dc:creator>
    <dc:date>2012-12-26T19:02:43Z</dc:date>
    <item>
      <title>Geoprocessing Script Tool Fails - scratchWorkspace tool or environment not found</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/geoprocessing-script-tool-fails-scratchworkspace/m-p/398460#M15478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a python script which when run in ArcMap works perfectly....&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When creating the script tool in ArcMap, "Always run in foreground" is unchecked, "store relative path names" is checked, and "run python script in process" is checked.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However, when I publish this script to an ArcGIS for Server 10.1 SP1 installation, executing the GPService fails with the following error from the logs: &lt;/SPAN&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "E:\arcgisserver\directories\arcgissystem\arcgisinput\EON\AirportsExportPython.GPServer\extracted\v101\toolboxes\AirportsExport.py", line 38, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outputFclass = arcpy.env.scratchWorkspace+"\\clipped.shp"&lt;BR /&gt;&amp;nbsp; File "c:\program files\arcgis\server\arcpy\arcpy\geoprocessing\_base.py", line 525, in get_&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return self[env]&lt;BR /&gt;&amp;nbsp; File "c:\program files\arcgis\server\arcpy\arcpy\geoprocessing\_base.py", line 575, in __getitem__&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return convertArcObjectToPythonObject(getattr(self._gp, item))&lt;BR /&gt;AttributeError: Object: Tool or environment &amp;lt;scratchWorkspace&amp;gt; not found&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the script: &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, csv, os arcpy.env.overwriteOutput = True&amp;nbsp; # Script arguments Selecting_Geometry = arcpy.GetParameterAsText(0) if Selecting_Geometry == '#' or not Selecting_Geometry: &amp;nbsp;&amp;nbsp;&amp;nbsp; Selecting_Geometry = r"E:\EON\data\templates.gdb\polygonTemplate"&amp;nbsp;&amp;nbsp; OutputType = arcpy.GetParameterAsText(1) if OutputType == '#' or not OutputType: &amp;nbsp;&amp;nbsp;&amp;nbsp; OutputType = "kmz"&amp;nbsp;&amp;nbsp; # Local variables: arcpy.env.scratchWorkspace = r"E:\EON\temp" outputFclass = arcpy.env.scratchWorkspace+"\\clipped.shp" AirportsLayer = r"E:\EON\layers\LandingFacilitiesOrganized.lyr" Airports = r"E:\EON\data\FAA.gdb\airports" exportLayer = arcpy.env.scratchWorkspace+"\\exportLayer.lyr"&amp;nbsp; # Process: Clip arcpy.Clip_analysis(Airports, Selecting_Geometry, outputFclass, "") OutputFile = arcpy.env.scratchWorkspace+"\\airportsExportResult.kmz" earthLayer = arcpy.mapping.Layer(AirportsLayer) for layer in earthLayer: &amp;nbsp;&amp;nbsp;&amp;nbsp; if layer.isGroupLayer: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue &amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.replaceDataSource(arcpy.env.scratchWorkspace, "SHAPEFILE_WORKSPACE", "clipped") earthLayer.saveACopy(exportLayer) arcpy.LayerToKML_conversion(exportLayer, OutputFile, "1", "false", exportLayer, "1024", "96", "CLAMPED_TO_GROUND") arcpy.SetParameterAsText(2,OutputFile) &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In short, this script clips a feature set to an input polygon, applies a complicated layer file to it, then exports to kmz.&amp;nbsp; I got this geoprocessing tool working correctly earlier, but was using arcpy.env.workspace instead of arcpy.env.scratchWorkspace, so the process wasn't referencing the clipped file in a jobs directory, but instead in the hardcoded workspace directory in the script.&amp;nbsp; Anyway, after some research I saw that I have to use scratchWorkspace for all intermediate data.&amp;nbsp; But this broke the geoprocessing service.&amp;nbsp; Any assistance would be greatly appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, Jay&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Dec 2012 19:02:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/geoprocessing-script-tool-fails-scratchworkspace/m-p/398460#M15478</guid>
      <dc:creator>Jay_Gregory</dc:creator>
      <dc:date>2012-12-26T19:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Script Tool Fails - scratchWorkspace tool or environment not found</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/geoprocessing-script-tool-fails-scratchworkspace/m-p/398461#M15479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I spoke too soon - this was an easy fix by just not hardcoding the scratch workspace in the script!&amp;nbsp; It works now...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2012 12:39:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/geoprocessing-script-tool-fails-scratchworkspace/m-p/398461#M15479</guid>
      <dc:creator>Jay_Gregory</dc:creator>
      <dc:date>2012-12-27T12:39:16Z</dc:date>
    </item>
  </channel>
</rss>

