Skip to main content

Python 3 runtime for ArcGIS Server on Linux

This topic is not relevant for ArcGIS Enterprise on Windows.

ArcGIS Server includes a Python 3 runtime for command-line ArcPy scripts. Python 3.x is installed with ArcGIS Server, but you can install a separate Python 3 runtime package that simplifies using Python 3 with ArcGIS Server.

Getting started

Python offers third-party libraries you can use in ArcGIS. Managing installed packages, however, can be a complex and time-consuming task. That is especially true if you work on multiple projects at once or share code with others. To simplify use of the Python 3 runtime on ArcGIS Server for Linux, use conda or Miniconda to download and install the arcgis-server-py3 package. The Python 3 runtime on ArcGIS Server for Linux requires a 64-bit installer.

If you do not already have conda or Miniconda, you can download it from the Anaconda website.

In a terminal, set the ARCGISHOME variable to the installation directory of ArcGIS Server when activating the conda environment for the Python 3 runtime on ArcGIS Server for Linux: export ARCGISHOME=/path/to/arcgis/server.

To access ArcGIS Python functionality, including ArcPy, install the arcgis-server-py3 package. In a conda environment, use the following command to install Python 3 runtime on ArcGIS Server for Linux:

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

The <ArcGIS Server version> value indicates the current version of the library, which is the same as your current version of ArcGIS Server, in the format n.n.n. For example, for ArcGIS Server 11.1, use the following:

conda install -c esri arcgis-server-py3=11.1.0

To verify the version of the arcgis-server-py3 package, use the following command:

conda list arcgis-server-py3

Installing the arcgis-server-py3 package adds ArcPy, including supported geoprocessing tools and all third-party requirements.

If you do not install the arcgis-server-py3 package, you must invoke Wine when you run the python.exe file installed to path/to/arcgis/server/framework/runtime/ArcGIS/bin/Python/envs/arcgispro-py3/ in the ArcGIS Server installation directory.

Migration

Using the Python 3 runtime with ArcGIS Server differs from using Python 2 with ArcGIS Server. You must account for changes in both ArcPy and Python itself.

Changes to functionality in ArcPy

Not all Python 2 geoprocessing tools are available in the Python 3 runtime for ArcGIS Server. For example, tools in the Schematics and Tracking Analyst toolboxes are not included. For a complete list of supported geoprocessing tools, see the readme file included in the arcgis-server-py3 package.

The arcpy.mapping module has been removed and replaced with an arcpy.mp module in ArcGIS Pro. The arcpy.na module also includes changes, many related to the change from arcpy.mapping to arcpy.mp.

Python version change

The ArcGIS Server Python runtime uses Python 3. This is a significant change because Python 3 is incompatible with Python 2. While fundamentally, much of the language is the same, many key details have changed considerably, including how strings and dictionaries work and how the standard library is organized.

At this time, the Python community has ported most key third-party libraries to Python 3, and the consensus is that developers create all new projects in Python 3.

ArcGIS Server no longer supports Python 2.7. To continue using your Python code with ArcGIS Server, you must ensure the code works in Python 3.

If you are doing a one-way conversion of code from Python 2 to Python 3, there is a 2to3 command-line utility you can use to automate much of the process. It is important to note that 2to3 is not a complete solution, and additional changes may be necessary.

Simpler Python scripts may not need changes and may run properly without modification.