Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS API for Python

ArcGIS API For Python

Work with maps and geospatial data in Python using The ArcGIS API for Python.

Use simple and efficient tools powered by Web GIS, for sophisticated vector and raster analysis, geocoding, map making, routing and directions. Administer, organize and manage users, groups and information items in your GIS.

This library enables access to ready-to-use maps and curated geographic data from Esri and other authoritative sources, and works with your own data as well. It integrates well with the scientific Python ecosystem and includes rich support for Pandas and Jupyter notebook.

See below for options to install arcgis and its dependencies:

There are multiple ways in which you can experience the ArcGIS API for Python. The ArcGIS API for Python is distributed as a conda package named arcgis. Conda is a popular Python package and environment manager application that helps you install and update packages such as the ArcGIS API for Python and their dependencies.

Installation for ArcGIS Pro 2.5.x and later

Python has a rich collection of packages that can be used in ArcGIS Pro. To simplify the use of Python packages, ArcGIS Pro includes a package management system called conda. Conda takes the guesswork and hassle out of installing and updating packages and their dependencies.

To further extend the versatility and utility of Python packages, multiple installations of Python can coexist on a single workstation, independent of one another. Each of these installations is referred to as a Python environment. Each Python environment can have its own set of packages, allowing you to switch between sets of Python functionality without uninstalling and reinstalling packages each time.

By default, ArcGIS Pro has a single conda environment, arcgispro-py3, which includes all Python libraries used by ArcGIS Pro as well as several others, such as scipy and pandas.

Installation using Python Package Manager

ArcGIS Pro 2.5 and later releases ship with conda and the arcgis package pre-installed. The functionality of conda is integrated into ArcGIS Pro through the Python Package Manager. The Python Package Manager removes many of the hurdles faced when writing Python code. It supports installing open-source and third-party libraries that are associated with an individual project, rather than the base Python installation. This simplifies the process of successfully sharing complex Python tools across multiple computers.

ArcGIS Pro 2.5 and later provide the Python Package Manager GUI to download and install any conda package. Access it through the ArcGIS Pro backstage area:

  • Open ArcGIS Pro with a new blank Project
  • Select the Project tab to access the Pro backstage (see screen shot below)
  • Select the Python menu option
  • You will see the already installed packages in the default arcgispro-py3 environment. In order to add more packages, you can do the following:
  • click on Manage Environments, click New python package manager mng envts
  • Type a name for the new environment and click Save

    python packagemanager new

  • Allow blue progress bar at the bottom of the dialog to complete. Proceeding before this completes could result in an incomplete environment that may not perform properly. python package manager progress bar

  • Select the Active radio button to make the new enviroment active

    python_package_manager_active

  • Click on 'Add Packages' button and type package name into the search bar.
  • Select the release you want to install.
  • Click 'Install' and accept the terms and conditions

Note: You may have to click the 'refresh' button to ensure you get the updated package information.

Installation using Python Command Prompt

ArcGIS Pro provides the Python Command Prompt to download and install any conda package.

  • Navigate to Start Menu > All Programs > ArcGIS > Python Command Prompt

Note: By default, the Python Command Prompt opens in the ArcGIS Pro default arcgispro-py3 environment directory, usually C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\, with the default conda environment active.

In order to add more packages, you need to create a clone of the default arcgispro-py3 environment. Follow the steps to create environment. You can change the default environment to the cloned environment using the command: proswap <new enviroment name>. Alternatively, to work with the activated environment, use conda utility to activate other environments.

  • Enter the following at the prompt:

    conda install -c esri arcgis=<release_number>

Upgrade package

  • To upgrade arcgis package using Python Package Manager:

    • Open ArcGIS Pro with a new blank Project
    • Select the Project tab to access the Pro backstage (see screen shot below)
    • Select the Python menu option
    • Use the Project Environment dropdown to chooose the appropriate environment
    • Select the Update Packages option
    • Choose the appropriate arcgis release from the list of packages with recent updates

      python_package_manager_update_pkg

    • Click the Update button

  • To upgrade using Python Command Prompt, Open Python Command Prompt

    Activate the environment containing the arcgis package and type:

    conda upgrade -c esri arcgis

Installation using Anaconda for Python Distribution

conda

Open a terminal application, navigate to the directory you want to work in and activate the conda environment you want to use with the ArcGIS API for Python. Install the API with the following command:

conda install -c esri arcgis

Note: You can also use the -n <environment_name> flag to install the package into an environment of your choosing.

install arcgis package mac

Pipenv

Pipenv is the official packaging tool for managing environments and installing packages from the Python Package Index (PyPI). To install the ArcGIS API for Python from PyPI in a new environment, create a new folder named your-folder. Open a terminal, and run cd /path/to/your-folder to change directories into your-folder. Then, enter the following command to simultaneously create a new environment and install the API in it:

pipenv install arcgis

Installation as a Docker image

Docker is a popular containerization technology. Docker containers bundle software in a complete file system with everything that is needed to run it. Docker containers run the same regardless of your operating system. To learn more about docker, refer to the official documentation.

The ArcGIS API for Python is shipped as a Docker image which you can download and power up whenever you want to use the API. These images when spun up into containers, run in an isolated environment without making any changes to your local file system.

Follow the steps below to get Docker on your computer and run the API:

  • Download docker and install it on your computer.
  • Once installed, run the following command in terminal to pull Docker image

    docker pull esridocker/arcgis-api-python-notebook

    docker pull command

  • Then spin the image into a container using the following command in terminal. Replace the <localport> with an available port number, for instance 8889.

    docker run -it -p <localport>:8888 esridocker/arcgis-api-python-notebook

  • When the container starts, it will provide a URL (with a one time token) to open your local Notebook instance. Copy the URL and paste it in your browser's address bar to use the notebooks.

Install Offline

1. While in a connected environment, download the appropriate software you'll need:
  • the latest version of the full Anaconda for Python 3x for your OS
  • the appropriate version of the API for Python package for your OS from Esri's channel on anaconda.org
    • The file names appear in this pattern: platform/arcgis-x.x.x-pyZZyyyyyyy-y.tar.bz2. Find your file by substituting:
      • your operating system platform for platform
      • the API release number for x.x.x
      • your Python version for ZZ.
      • The yyyyyyy_y refers to a hash number created for each conda package uploaded to the channel

For instance, if you are installing the Python API 1.6.2 on Windows 64-bit for Python 3.7, download the win-64/arcgis-1.6.2-py37h42bb103_633.tar.bz2 package.

2. Configure Anaconda for use in the disconnected enviroment:
  • Install Anaconda from your install location. Once installed, you can use the Anaconda Navigator GUI application or the Anaconda Prompt command line console to operate the software. The procedure below outlines using the Anaconda Prompt and the conda utility on Windows:

    First, open Anaconda Prompt. All subsequent commands are run inside this prompt:

    Start > Anaconda3 (64-bit) > Anaconda Prompt

    1. Configure Anaconda for offline use. See Conda Configuration for full details:

      conda config --set offline True

    2. Create a new environment, including python and six packages:

      conda create -n <my_env_name> python six

    3. Activate the environment:

      conda activate <my_env_name>

    4. Install the API for Python package, having downloaded the bz2 file that matches the appropriate platform, Python version and API release you are using:

      conda install /path_to_package_download_folder/platform/arcgis-x.x.x-pyZZyyyyyyy-y.tar.bz2

      The conda utility will pull all the arcgis package dependencies from the installed set of Anaconda libraries instead of searching the internet.

3. Verify the install:
  • At this point, all modules, classes and functions are available in the API for use in your Python scripts or Jupyter notebooks except the Map Widget. You can verify your install by making a connection to your GIS and printing properties:
    gis = GIS("url_to_your_gis", "username", "password")
      print(f"Connected to {gis.properties.portalHostname} as {gis.users.me.username}")
    
  • The map widget is only supported within Jupyter applications. Follow these additional steps to use the map widget in a disconnected environment:

    • install the jupyterlab package for visualizing with maps in either Jupyter Notebook or Jupyter Lab:

      conda install jupyterlab

    • enable the map widget by running these 2 commands in succession:

      1. jupyter nbextension enable --py --sys-prefix widgetsnbextension

      2. jupyter nbextension enable --py --sys-prefix arcgis

    • proceed to Test your install with the Jupyter Notebook to verify the proper installation of the map widget.

      NOTE: You may need to configure the map widget to use the Javascript API shipped with the portal you're connecting to in the disconnected environment. If gis.map() does not return a map, run the following code to configure the map widget with the Javascript API shipped with the portal:

      MapView.set_js_cdn("https://your-portal-host/jsapi4/")
      

NOTE: The Web GIS must have a Geocoder configured as a Utility Service to display a map. See here for details if your portal does not have one.

Installation for older versions

You can click here to install argis for older versions.

Install deep learning dependencies

If you already have an environment with the arcgis package installed, you can further install its deep learning dependencies to take advantage of the arcgis.learn module. Some of the deep learning samples available here can be referenced to understand the workflow.

Using the Deep Learning Frameworks Installer

To work with the deep learning tools in ArcGIS Pro 2.6, you need to install supported deep learning frameworks packages.

For instructions on how to install deep learning packages, see the Install Deep Learning Frameworks Guide for ArcGIS Pro 2.6.

ArcGIS Pro 2.6 deep learning installer is now available at https://github.com/Esri/deep-learning-frameworks. This installer includes a broad collection of components, such as PyTorch, TensorFlow, Fast.ai and scikit-learn, for performing deep learning and machine learning tasks, a total collection of 95 packages. It adds packages to the default arcgispro-py3 environment. Any subsequent clones of that environment will also include this full collection of packages.

Install using Python Command Prompt or Anaconda

To install deep learning packages in ArcGIS Pro, first ensure that ArcGIS Pro is installed. Using the steps below, you will create a new Python deep learning environment by cloning the default Python environment arcgispro-py3 using the above above. Activate the cloned environment.

For opening Python Command Prompt navigate to
Start Menu > All Programs > ArcGIS > Python Command Prompt

If using Anaconda, Open a terminal application, navigate to the directory you want to work in and activate the conda environment.

Next, you will install the following Python packages: Tensorflow, fast.ai, Keras, Pytorch, Scikit-image, Pillow, and Libtiff. Keep in mind you will be installing specific versions of these packages indicated in the installation steps below. The tools only work with these specific versions.

  • Install the dependencies using the following command:

    conda install -c esri -c fastai -c pytorch arcgis=1.8.2 scikit-image=0.15.0 pillow=6.2.2 libtiff=4.0.10 fastai=1.0.60 pytorch=1.4.0 torchvision=0.5.0 --no-pin

  • For TensorFlow support (optional), use the following command:

    conda install -c esri -c fastai -c pytorch arcgis=1.8.2 scikit-image=0.15.0 pillow=6.2.2 libtiff=4.0.10 fastai=1.0.60 pytorch=1.4.0 torchvision=0.5.0 tensorflow-gpu=2.1.0 --no-pin

  • For Multispectral data support (optional and needed only for Anaconda users)

    conda install -c esri gdal=2.3.3

Test your install with jupyter notebook

To verify your arcgis installation, run the following commands in jupyter notebook:

In [1]:
from arcgis.gis import GIS
my_gis = GIS()
m = my_gis.map()
m
Out[1]:

To verify deep learning environment, run the following commands:

import fastai

import torch

import arcgis

Run this command to check if cuda device is picked up for training a model on GPU.

torch.cuda.is_available()

torch.zeros((3, 224, 224)).cuda()

Note: If you face an error pointing to some issue with driver, you need to update driver.

This overview describes how to use ArcGIS API for Python to write Python code, incorporating capabilities such as mapping, query, analysis, geocoding, routing, portal administration, and more. Browse the sample notebooks to get started. You may choose to experience these sample notebooks in a live environment as they are available as ArcGIS Notebooks.

These are temporary environments which are erased after you close the browser tab. If you would like to save your changes, download your notebooks from the File menu of the Jupyter notebook IDE.


Feedback on this topic?