Skip To Content

ArcGIS Server and ArcPy

ArcGIS includes the ArcPy site package that you can use for managing data store items and publishing service definitions with Python. ArcPy also allows you to run geoprocessing tools from ArcGIS Server machines using Python.

ArcPy complements the server administration operations in the ArcGIS REST API. For example, using ArcPy, you can convert map documents to service definitions and upload them to the server, change the paths of layers in a map document, or add more layers and publish a service.

You can use ArcPy with ArcGIS Server in the following ways:

  • Register databases and folders with ArcGIS Server.
  • Analyze your map documents and use them to create service definitions.
  • Analyze your imagery or geoprocessing model results and use them to create service definitions.
  • Publish a service definition as an ArcGIS Server service.
  • Publish all service definitions in a folder to ArcGIS Server.

Tip:

ArcGIS Server 10.9.1 installs Python 3 to the following location by default: C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\Scripts\propy.bat.

If you enable ArcMap Runtime Support (and, therefore, Python 2.7) in an ArcGIS Server 10.9.1 site, the Python 2.7 files install to C:\Python27 on the ArcGIS Server machine by default.

ArcGIS Server 10.9.1 is the last release that will include an installation of Python 2.7.

This section of the documentation contains examples of ArcPy code that accomplish various tasks in ArcGIS Server.

You can add ArcPy to an existing Python 3 environment, as long as its package versions are not in conflict. To add ArcPy, use conda to install ArcPy from the Esri channel on Anaconda Cloud. From the conda prompt, run the following command with the appropriate release number:

conda install arcpy-server=10.9.1 -c esri