ArcGIS Server provides the option to use a Python 3 runtime for command line ArcPy scripts. Select tools can be executed with a Python 3.5 runtime that is installed independently of ArcGIS Server.
In earlier releases of ArcGIS Server on Linux, Python scripts could only be executed in a Linux shell using the Python 2.7 runtime included with ArcGIS Server. This experience had limitations regarding the use of third-party libraries and working with paths.
You can get started using the Python 3 runtime on ArcGIS Server for Linux by using conda to download and install the arcgis-server-<arcgis version number>-py3 package.
Python has a rich ecosystem of preexisting code packages that can be leveraged within ArcGIS, but managing which packages are installed on a system can be a complex and time consuming task, especially when working on multiple projects at once or trying to share code with others.
To leverage this versatility, the Python community has designed methods to create projects in multiple versions of Python, while trivializing the process of installing nearly all publicly available Python packages. The most popular and widely used Python package manager is conda. Integrating conda with ArcGIS Server allows you to use the functionality in Python's ecosystem of open-source and third-party packages from within ArcGIS Server. It allows you to quickly install, run, and update packages and their dependencies for use in your Python code.
If you do not already have conda, it can be downloaded here.
To access ArcGIS Python functionality, including ArcPy, the arcgis-server-<arcgis version number>-py3 package can be installed directly from conda. From within a conda environment, use the following command:
conda install -c esri arcgis-server-<arcgis version number>-py3
Installing the arcgis-server-<arcgis version number>-py3 package will add ArcPy, including supported geoprocessing tools and all third-party requirements.
How you use the Python 3 runtime with ArcGIS Server is different from the Python 2 ArcGIS Server and other ArcGIS products, including ArcGIS Desktop. There are two primary differences to accommodate: the change of Python from 2 to 3 and differences within arcpy itself.
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 that are not included are the tools in the Parcel Fabric, Schematics, and Tracking Analyst toolboxes. Additional tools in other toolboxes are also not available. For a full listing of supported geoprocessing tools, see the readme file included in the arcgis-server-<arcgis version number>-py3 package.
The arcpy.mapping module has been removed and has been 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.5. This is a significant change from other ArcGIS products that have used and continue to use releases in the Python 2 line. The Python 3 line of releases are 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.
Python 3 has been in active development for several years, coexisting with Python 2 as the Python community has ported over. At this time, the majority of key third-party libraries have ported over to Python 3, and in the Python community the consensus is that all new development projects will be done in Python 3.
A key decision point will be whether you will update your Python code to work in both Python 2 and 3. If you're doing a one-way conversion of code from Python 2 to Python 3, there is a 2to3 command line utility that can be used to automate much of the process. This utility is available with both Python 2 and 3. 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.
An excellent reference for porting to Python 3 and migration strategies is in Lennart Regebro's Porting to Python 3 at the http://python3porting.com/ website. It is possible to write scripts that will run in Python 2 and Python 3.
Keep in mind that simpler Python scripts may not need any changes and may run properly without modification.