Skip To Content

ArcGIS Server and ArcPy

ArcGIS includes the ArcPy site package, which you can use for managing data store items and publishing service definitions with Python. ArcPy also allows you to run most of the same geoprocessing tools from ArcGIS Server machines using Python that you can run from ArcGIS Pro. By default, the toolsets are in /arcgis/server/framework/runtime/ArcGIS/Resources/ArcToolBox/Toolboxes.

ArcPy complements the server administration operations in 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.

Examples of how you can use ArcPy with ArcGIS Server include the following:

  • Register databases and folders with ArcGIS Server.
  • Analyze map documents and use them to create service definitions.
  • Analyze 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 installs Python 3.x to the following location: <arcgis_server_installation_directory>/arcgis/server/tools/python3. Connect as the user who installed ArcGIS Server, open a command prompt, and change directories to the python3 location. Next, type ./python3 to launch an active Python 3 environment using the ArcGIS Pro runtime.

If you upgraded the ArcGIS Server site from 10.9.1 or earlier, the old installation location and script remain, but the old script serves as a symbolic link that directly references the python3 script.

You can add ArcPy to an existing Python 3 environment, as long as its package versions do not conflict.

To simplify the use of Python 3 runtime, use conda or Miniconda to download and install the arcgis-server-py3 package. From a conda environment, run the following command with the appropriate ArcGIS Server software version number:

conda install -c esri arcgis-server-py3=<software version>

Replace the <software version> value with the current version of your ArcGIS Server installation. The version number must be supplied in the format n.n.n—for example, for ArcGIS Server 11.1, use 11.1.0.

For more information, see Python 3 runtime for ArcGIS Server on Linux.