Install and set up

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.

See below for options to install both conda and the arcgis package:

Step 1: Get Conda

Get Conda with ArcGIS Pro

Get Conda with Anaconda for Python Distribution

Anaconda installs Python, conda for package management and many useful Python packages. Since the ArcGIS API for Python requires Python 3.5 or later, proceed to the Anaconda download page and download the appropriate 3x version of the Anaconda software:

Once the Anaconda software is installed, proceed to Install the arcgis package with the Anaconda for Python Distribution to install the API.

Step: 2 Install the arcgis package

Install using ArcGIS Pro Python Package Manager

ArcGIS Pro 1.4 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
  • Click the 'Add Packages' button and type arcgis into the search bar
  • You may have to click the 'refresh' button to ensure you get the complete list of available releases. You will be able to install up to release 1.2.5. To upgrade to a package beyond the 1.2.5 release, see Upgrade the arcgis package
  • Select the release you want to install
  • Click 'Install' and accept the terms and conditions

install using ArcGIS Pro

To use the API in different IDEs, proceed to Using the API

Install using Python Command Prompt

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

  • Enter the following at the prompt:

    conda install -c esri arcgis
    
    

python command prompt

To use the API in different IDEs, proceed to Using the API

NOTE: Depending on how you installed Pro, you might have to start this prompt with elevated privileges.

Install using Anaconda for Python Distribution

Open a terminal application and install the API with the following command:

conda install -c esri arcgis

install arcgis package mac

To use the API in different IDEs, proceed to Using the API

Install using pipenv or pip

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

After running this command, you will notice that a new file named Pipfile was created in your-folder. A Pipfile contains package information that represents a python environment. Open your terminal and make sure you are still in the your-folder directory; then, run pipenv shell. You have now activated your python environment, the environment that contains the arcgis package! You can run jupyter notebook or python in this environment to start using the API.

Pipenv differs from conda and other environment managers in that environments are specific to the folder that contains the Pipfile. In this way, pipenv's use of Pipfile is similar to how npm uses package.json. To learn more about installing and using pipenv, click here or here.

Tip: You can run any command in an environment without activating it by running pipenv run {insert_command_here} in a directory with a valid Pipfile.

Pip

Pip is the predecessor of pipenv, and can also be used to install packages from PyPI (but you must manage environments with seperate tools like virtualenv). To install the API with pip, open a terminal and enter the following command:

pip install arcgis

Disclaimer

You should avoid mixing conda with pipenv/pip: they are completely seperate package managers. It is recommended that you use conda to install the API if you are a beginner user. Read more about the differences here and here.

Note: when installing the ArcGIS API for Python with pipenv/pip, some dependencies may require Microsoft Visual C++ 14.0. If you see any errors related to this, either install the Microsoft Visual C++ tools or install the API without dependencies.

Install with minimum dependencies

Both conda install -c esri arcgis and pip install arcgis will install all of the dependencies outlined in the system requirements section. However, the API can function in a 'stripped down' state with only a few dependencies. This means you can manually manage the dependencies on your system if you don't want to use every feature of the API. As of v1.8.0 of the Python API, the minimum dependencies needed are:

  • six
  • requests
    • This library has its own dependencies that must be included
  • requests_toolbelt
  • requests_ntlm
    • This library has its own dependencies that must be included
  • ntlm_auth

To install the API with no dependencies, simply add the --no-deps flag to any install command, i.e. conda install -c esri arcgis --no-deps or pip install arcgis --no-deps. You can then manually choose which dependencies to add to your Python environment.

Install deep learning dependencies for arcgis.learn module

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.

Install using the Python Command Prompt (ArcGIS Pro 2.5) or Anaconda

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

Install the dependencies using the following command:

conda install -c esri -c fastai -c pytorch arcgis=1.8.1 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.1 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 gdal=2.3.3


Upgrade the arcgis package

ArcGIS Pro 2.2

ArcGIS Pro 2.2 ships with the ArcGIS API for Python 1.4.1 installed. The initial ArcGIS Pro installation creates a default read-only conda environment named arcgispro-py3. To upgrade the ArcGIS API for Python package, use the Python Package Manager to create a new environment and then install the latest release of the ArcGIS API for Python:

  • Open ArcGIS Pro with a new blank Project

  • Select the Project tab to access the Pro backstage (see screenshot below)

  • Select the Python menu option

  • Click Manage Environments, then 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

  • Close the Manage Environments dialog and close ArcGIS Pro

  • Open the Python Command Prompt: Start > All Programs > > ArcGIS > ArcGIS Pro > Python Command Prompt

  • Type the command below: conda upgrade -c esri arcgis

    upgrade_command_prompt

  • Type y to Proceed:

    upgrade command

  • Type conda list arcgis to verify the upgrade: upgrade verification

ArcGIS Pro 2.1

ArcGIS Pro 2.1 ships with the ArcGIS API for Python 1.2.5 installed. To update to the newest release, proceed to to run the command below from either a Terminal window with the arcgispro-py3 environment active, or the Python Command Prompt:

    conda upgrade -c esri --no-pin arcgis

ArcGIS Pro 1.4 and 2.0.x

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

Terminal Window or Python Command Prompt

Activate the environment containing the arcgis package and type:

conda upgrade -c esri arcgis

ArcGIS Pro 1.3

ArcGIS Pro 1.3 will install the ArcGIS API for Python 1.0 (the arcgis 1.0 package) release. To upgrade the arcgis package you would have to install a later release of ArcGIS Pro.


Using the API

Start the Jupyter notebook installed with the API:

Windows:

  • Navigate to Start Menu > All Programs > ArcGIS > Python Command Prompt
  • Change to a directory with notebooks in it, or one where you want to create notebooks
  • Enter the following at the prompt to start jupyter:
jupyter notebook

macOS and Linux:

  • Open a terminal application
  • Change to a directory with notebooks in it, or one where you want to create notebooks
  • Enter the following at the prompt to start jupyter:
jupyter notebook

The Jupyter dashboard opens in a web browser. For instructions on using the Jupyter Notebook, refer to the how to use the notebook environment guide.


Test your install with jupyter notebook

From the Jupyter Notebook dashboard:

  • Windows:  Click New > Python 3
  • macOS and Linux:  Click New > Python[default]

Enter the following lines of code. You should see a map draw as below:

from arcgis.gis import GIS
my_gis = GIS()
m = my_gis.map()
m

Learn more about the API using the guide and try out the samples.


Install 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 ghcr.io/esri/arcgis-python-api-notebook

  • 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 ghcr.io/esri/arcgis-python-api-notebook

  • When the container starts, it will provide a 127.0.0.1 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.

Full Conda documentation located here. For advanced users or those needing information on specific environments, see Configuration for options to configure various aspects of conda.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.