ArcGIS Server provides the option to use 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 that you can use in ArcGIS, but managing which packages are installed can be a complex and time-consuming task, especially when working on multiple projects at once or trying to share code with others. To simplify the 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 will add 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
How you use the Python 3 runtime with ArcGIS Server is different than the Python 2 ArcGIS Server. There are two primary differences you must accommodate within ArcPy and the change of Python versions.
Changes to functionality in ArcPy
Many geoprocessing tools will continue to be available in the Python 3 runtime for ArcGIS Server; however, some will not. Tools in the Parcel Fabric (ArcMap), Schematics, and Tracking Analyst toolboxes are not included. Additional tools in other toolboxes are also not available. 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; the Python 3 line of releases is incompatible with the Python 2 line. 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 over the majority of key third-party libraries to Python 3 and, in the Python community, the consensus is that all new development projects will be done 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're 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, while an excellent tool, is not a complete solution (it is sometimes estimated as a 95 percent solution), and additional changes may be necessary.
Keep in mind that simpler Python scripts may not need any changes and may run properly without modification.