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 C:\Program Files\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 by default: C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python.

To run an ArcPy script, open ArcGIS > Python 3 Command Prompt from the Windows start menu. This starts a Windows Terminal session with an active python3 environment using the ArcGIS Pro runtime. At the command prompt, type python <path to my script.py>, replacing <path to my script.py> with the path to and name of your script.

Another way to run an ArcPy script on an ArcGIS Server machine is to run the propy.bat file from a command window such as the Windows command prompt or a Microsoft PowerShell session. The propy.bat file is installed to C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\Scripts\propy.bat by default. Type the path to the propy.bat file followed by the ArcPy script location and name. For example, type C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\Scripts\propy.bat <path to my script.py>, replacing <path to my script.py> with the path to and name of your script.

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