Skip To Content

Deploying custom Python packages for ArcGIS Server

ArcGIS Server (Windows) and ArcGIS Server (Linux) include Python 2.7 for Windows 64 bit. At ArcGIS Enterprise 10.5 and later, the conda environment is included with ArcGIS Server (Windows) and ArcGIS Server (Linux). The conda environment is based on Python 3. The Python installation of ArcGIS Server includes packages such as numpy and matplotlib. However, if you want to install additional custom Python packages, follow the steps below.

ArcGIS Server (Windows) and ArcGIS Pro

Similar to ArcGIS Pro, ArcGIS Server uses conda to manage Python environments. To clone an existing Python environment, and activate it, follow the steps below.

Note:

The steps below are for geoprocessing services published from ArcGIS Pro using the arcpy module based on your ArcGIS Pro conda environment. For more information about the Python environment in ArcGIS Pro, see Python in ArcGIS Pro. It is recommended that you clone the default Python environment to make updates. Only one Python environment at a time can be activated for ArcGIS Server.

  1. To activate the current environment, open a command prompt, and run the proenv.bat file under . <ArcGISServer_InstallDir>\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\Scripts.
  2. To clone the ArcGIS Server default environment, run the following, specifying the name of the new environment and the directory where it will reside: conda create --clone arcgispro-py3 --name %LocalAppData%\ESRI\conda\envs\new_env_name
  3. To switch to the new cloned environment, use proswap (proswap new_env_name).
  4. Right-click the ArcGIS Monitor Server service in the Windows Services manager and click Restart. This will take a few minutes until all services are back online.
  5. Additional packages can be installed using conda command line utilities. The conda executable is at . <ArcGISServer_InstallDir>\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\Scripts.

For additional information about using and working with conda, see Introduction to conda.

ArcGIS Server (Windows) and ArcMap

Note:

The following steps are for geoprocessing services published from ArcMap and the arcpy module based on Python 2.7.

  1. Download the Windows 64-bit version of the package.
  2. Browse to your download location.
  3. Double-click the .msi or .exe file to install the package.

Custom packages are typically installed in the C:\Python27\ArcGISx6410.7\lib\site-packages directory.

ArcGIS Server (Linux)

The following steps are for ArcGIS Server (Linux):

  1. Download the Windows 64-bit version of the package.
  2. Start the wine explorer application. At the terminal, paste this command:

    . <ArcGISServer_InstallDir>/arcgis/server/framework/etc/arcenv; wine explorer &

  3. Browse to your download location (remember that Z:\ is mapped to your system's /.)
  4. Double-click the .msi or .exe file to install the package.

Custom packages are typically installed in the <ArcGISServer_InstallDir>/arcgis/server/framework/runtime/.wine/drive_c/Python27/ArcGISx6410.7/lib/site-packages directory.

Testing custom Python packages

To test that the package installed properly, write a Python script that imports the package you installed, and run the script. If you are unfamiliar with running stand-alone scripts, follow the steps below.

  1. Open the terminal window.
  2. Run the server's Python with the script as an argument, for example:<ArcGISServer_InstallDir>/arcgis/server/tools/python ~/projectX/mytestscript.py

Note:

The Python libraries installed by an ArcGIS Server (Linux) installation are Windows 64-bit Python. Therefore, you should always use the Windows path separator (\) for stand-alone Python scripts when accessing data and other Python modules. Also, be aware that there is a Z:\ that is mapped to the Linux system's /. In a Python script, you can access data and other Python modules using Z:\ mapping. For example, data in /myuser/myproject/data can be accessed using z:\myuser\myproject\data.

This does not apply to Python scripts you publish from ArcGIS Desktop, because the publishing process converts all paths to the correct format.

Related topics