<?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 Re: ArcPy Project failing as GP Service in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014851#M59442</link>
    <description>&lt;P&gt;Try setting the output location for project to a known folder location that exists on the server instead of&amp;nbsp;&lt;FONT face="courier new,courier"&gt;script_path&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jan 2021 21:10:20 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2021-01-07T21:10:20Z</dc:date>
    <item>
      <title>ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014840#M59438</link>
      <description>&lt;P&gt;I have an python tool that runs fine in ArcGIS pro. I was able to publish as a service to my ArcGIS Enterprise however when I try to run the service it gives an error. It looks like the it is hung up when trying to call&amp;nbsp;arcpy.Project_management. Any ideas on why this would run fine in Pro but not as a GP service? Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;I&gt;esriJobMessageTypeError&lt;/I&gt;: Traceback (most recent call last): File "&amp;lt;string&amp;gt;", line 156, in execute File "&amp;lt;string&amp;gt;", line 441, in getMessages File "d:\program files\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\management.py", line 11492, in Project raise e File "d:\program files\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\management.py", line 11489, in Project retval = convertArcObjectToPythonObject(gp.Project_management(*gp_fixargs((in_dataset, out_dataset, out_coor_system, transform_method, in_coor_system, preserve_shape, max_deviation, vertical), True))) File "d:\program files\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\geoprocessing\_base.py", line 511, in &amp;lt;lambda&amp;gt; return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 000208: Error creating output feature class Failed to execute (Project).&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="python"&gt;# what to do with a polygon
        logging.debug(
            "Input feature is a polygon based on config, buffer will not be created")
        poly = arcpy.AsShape(feature["geometry"], True)

        try:
            wkid = feature["geometry"]["spatialReference"]["latestWkid"]
        except Exception:
            wkid = feature["geometry"]["spatialReference"]["wkid"]
            pass

        in_sr = arcpy.SpatialReference(wkid)
        poly_fc = arcpy.CreateFeatureclass_management(
            "in_memory", "tempPoly", "POLYGON", spatial_reference=in_sr)[0]
        logging.debug("Spatial Reference of poly_fc: " +
                      arcpy.Describe(poly_fc).spatialReference.name)

        # Open an insert cursor
        with arcpy.da.InsertCursor(poly_fc, ["SHAPE@"]) as cursor:
            # add the poly to the feature class
            cursor.insertRow([poly])

        # reproject the poly feature class to 4326 if it's not already so the
        # buffer output will be in 4326 and be more accurate
        if wkid == 4326:
            event_poly = poly_fc
        else:
            projected_poly = os.path.join(script_path,"prjPoly.shp")
            arcpy.Project_management(
                poly_fc, projected_poly, arcpy.SpatialReference(4326))
            arcpy.CopyFeatures_management(projected_poly, event_poly)
            arcpy.Delete_management(projected_poly)
            logging.debug("event Poly feature count: " +
                          str(arcpy.GetCount_management(event_poly).getOutput(0)))
            logging.debug("event Poly spatial reference: " +
                          arcpy.Describe(event_poly).spatialReference.name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 20:50:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014840#M59438</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-01-07T20:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014845#M59439</link>
      <description>&lt;P&gt;I'm pretty sure&amp;nbsp;arcpy.Project_management() is not compatible with in_memory workspace. Maybe while it's running as a GP service it gets run in such a manner and is erroring out.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 21:00:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014845#M59439</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-01-07T21:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014846#M59440</link>
      <description>&lt;P&gt;It is working fine in ArcGIS Pro though. Is the incompatibility only on arcpy available on the ArcGIS server?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 21:03:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014846#M59440</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-01-07T21:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014850#M59441</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/project.htm" target="_blank"&gt;Project (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The&amp;nbsp;&lt;SPAN class="usertext"&gt;in_memory&lt;/SPAN&gt;&amp;nbsp;workspace is not supported as a location to write the output dataset.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;From Pro 2.7 help.&amp;nbsp; If you are using something else other than Pro, then you would have to consult that help.&amp;nbsp; For example&lt;/P&gt;&lt;P&gt;&lt;A href="https://enterprise.arcgis.com/en/server/latest/get-started/windows/about-arcgis-server-documentation.htm" target="_blank"&gt;ArcGIS Server documentation—ArcGIS Server | Documentation for ArcGIS Enterprise&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 21:09:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014850#M59441</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-01-07T21:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014851#M59442</link>
      <description>&lt;P&gt;Try setting the output location for project to a known folder location that exists on the server instead of&amp;nbsp;&lt;FONT face="courier new,courier"&gt;script_path&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 21:10:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014851#M59442</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-01-07T21:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014852#M59443</link>
      <description>&lt;P&gt;The error&lt;/P&gt;&lt;BLOCKQUOTE&gt;ERROR 000208: Error creating output feature class Failed to execute (Project).&lt;/BLOCKQUOTE&gt;&lt;P&gt;indicates the problem is creating the output from the Project tool.&amp;nbsp; Since you haven't shared how the script_path variable is set, it is difficult to say anything more specific.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 21:11:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014852#M59443</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-01-07T21:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014853#M59444</link>
      <description>&lt;P&gt;I'm not sure where your outputs are set to, but if for example the script_path folder is not registered to the server datastore, it will fall over.&amp;nbsp; The error certainly appears to be related to the server being unable to create an output somewhere.&lt;/P&gt;&lt;P&gt;Perhaps share the full code and script tool parameters to get more detailed advice.&lt;/P&gt;&lt;P&gt;Blake is right, as far as I know, Project will only work if output to a physical location, but I'm assuming script_path is a folder which is why it works in desktop.&amp;nbsp; You can however cheat this by specifying a scratch workspace of scratch GDB as the output location.&amp;nbsp; On publishing, Server seems to interpret this and modify the path to its own scratch environment.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 21:12:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1014853#M59444</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-01-07T21:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015049#M59461</link>
      <description>&lt;P&gt;The output is not being written to in_memory. It is being output as shapefile.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 15:31:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015049#M59461</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-01-08T15:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015052#M59462</link>
      <description>&lt;P&gt;script_path is set using&amp;nbsp;sys.path[0]&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 15:36:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015052#M59462</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-01-08T15:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015058#M59463</link>
      <description>&lt;P&gt;Have you confirmed with print statements that it isn't attempting to overwrite an existing file without you setting arcpy.env.&lt;SPAN&gt;overwriteOutput = True somewhere?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 15:42:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015058#M59463</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-01-08T15:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015061#M59464</link>
      <description>&lt;P&gt;I can't share all the code as it has proprietary business logic but I will share as much as possible. Yes the current output of Project is to a shapefile in the same directory as the python tool by using&amp;nbsp;&lt;SPAN&gt;sys.path[0] to set the path.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To elaborate a bit more this tool was originally&amp;nbsp;created in ArcMap and published to my current 10.8.1 server. and worked fine. I am converting it to ArcGIS Pro as we plan on not using ArcMap any longer. I might modifications to get it running with python 3 and it does work fine in ArcGIS Pro. Publishing&amp;nbsp;to Server 10.8.1 as a GP service is where I have the issue.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 15:48:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015061#M59464</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-01-08T15:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015064#M59465</link>
      <description>&lt;P&gt;script_path is currently being set as&amp;nbsp;&lt;SPAN&gt;sys.path[0] which should be a good path. But I should confirm that. I will try loggint his path out before I run the reprojection to ensure the path is valid. I can also try hardcoding the path to see if that helps. That will be good from a troubleshooting perspective but I do not like hardcoding paths so I will have to find a better way if it does work out.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 15:54:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015064#M59465</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-01-08T15:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015075#M59469</link>
      <description>&lt;P&gt;So I checked the output path of sys.path[0] when the tool runs and it is&amp;nbsp;D:\arcgisserver\directories\arcgissystem\arcgisinput\GPTools\ExposureTool.GPServer\extracted\p20\smsalertgppublish_test. This is a valid directory on the server. and I confirmed there is no existing file there that would need to be overwritten.&amp;nbsp; I also use the same sys.path[0] to create log files for this tool which are being generated successfully indicated it is not a write permission issue on the folder.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 16:21:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015075#M59469</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-01-08T16:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015101#M59470</link>
      <description>&lt;P&gt;Thanks to the suggestion on the scratch GDB I was able to get this working. I am still baffled on why outputting as a shape file no longer works as it has in the past. Either way using the scratch GDB is probably a better approach anyway.&lt;/P&gt;&lt;P&gt;Here is what I changed in case anyone else runs into this.&lt;/P&gt;&lt;P&gt;I changed this line: projected_point = os.path.join(script_path, "projectedPoint.shp")&lt;BR /&gt;To this: projected_point = os.path.join(arcpy.env.scratchGDB, "projectedPoint")&lt;/P&gt;&lt;P&gt;Thanks to all for the help!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 17:26:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015101#M59470</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-01-08T17:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015105#M59471</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/16061"&gt;@BrianLeroux&lt;/a&gt;&amp;nbsp;can we assume that you are raw encoding the path just in case python gets involved because...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;pth = "D:\arcgisserver\directories\arcgissystem\arcgisinput\GPTools\ExposureTool.GPServer\extracted\p20\smsalertgppublish_test"

os.path.join(pth, "test.shp")
'D:\x07rcgisserver\\directories\x07rcgissystem\x07rcgisinput\\GPTools\\ExposureTool.GPServer\\extracted\\p20\\smsalertgppublish_test\\test.shp'&lt;/LI-CODE&gt;&lt;P&gt;would obviously be invalid with the &lt;STRONG&gt;r&lt;/STRONG&gt; before "D:\....&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 17:31:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015105#M59471</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-01-08T17:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015131#M59472</link>
      <description>&lt;P&gt;I ended up fixing by using a scratch GDB for the Project output. I think overall a better approach anyway. I appreciate your input.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 18:06:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015131#M59472</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-01-08T18:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015134#M59473</link>
      <description>&lt;P&gt;yes, but keep it in mind when working with python 3... unicode opens a whole new world of issues for path construction&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 18:08:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015134#M59473</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-01-08T18:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Project failing as GP Service</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015148#M59474</link>
      <description>&lt;P&gt;Noted! Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 18:32:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-project-failing-as-gp-service/m-p/1015148#M59474</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-01-08T18:32:50Z</dc:date>
    </item>
  </channel>
</rss>

