Skip to content

Use the ArcGIS API for Python in a disconnected environment.

There are two ways to install the ArcGIS API for Python in a disconnected environment, one is using conda and the other is using pixi

Conda steps

Following are the steps to install the ArcGIS API for Python in a disconnected environment using conda

1. Download Software

While in a connected environment, you'll need to download the appropriate software you'll need:

  • the latest version of either Anaconda or Miniconda for Python 3.x for your OS:

  • the appropriate version of the API for Python package and its dependencies for your target platform. Supported target platforms are currently:

    • Windows 64-bit (win-64)
    • Linux 64-bit (linux-64)
    • macOS Intel (osx-64)
  • If your source (connected) environment is a different platform than your target platform:

    • Set the CONDA_SUBDIR environment variable to your target (disconnected) platform, either win-64, linux-64, or osx-64. For example:

      • Bash: export CONDA_SUBDIR=win-64
      • PowerShell: $env:CONDA_SUBDIR="linux-64"
      • cmd: set CONDA_SUBDIR=linux-64
  • Create an empty directory for downloads, for example:

    • Windows: mkdir C:\Users\me\Downloads\arcgis_offline
    • macOS: mkdir ~/Downloads/arcgis_offline
  • Set the CONDA_PKGS_DIRS environment variable to your empty download directory from the previous step. For example:

    • Bash: export CONDA_PKGS_DIRS=~/Downloads/arcgis_offline
    • PowerShell: $env:CONDA_PKGS_DIRS="C:\Users\me\Downloads\arcgis_offline"
    • cmd: set CONDA_PKGS_DIRS=C:\Users\me\Downloads\arcgis_offline
  • To download the ArcGIS API for Python and its dependencies, run:

    conda create --name arcgis_offline --override-channels --download-only -c esri -c defaults arcgis arcgis-mapping

    • To download a specific version of arcgis and arcgis-mapping, use the following command:

      conda create --name arcgis_offline --override-channels --download-only -c esri -c defaults arcgis=<release_number> arcgis-mapping=<release_number>

    • You may see a message:

      CondaExitZero: Package caches prepared. UnlinkLinkTransaction canceled with --download-only option

      This indicates successful download.

  • Copy all files (you may skip the subdirectories) from your download directory to your disconnected environment, see below.

2. Configure Anaconda:

Install Anaconda from your location in the disconnected environment. 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. Obtain the package cache directories in your disconnected environment

    conda config --show pkgs_dirs

  3. Copy the files from your connected environment to one of the cache directories specified in the previous step.

  4. Create a new empty environment:

    conda create -n <my_env_name>

  5. Activate the environment:

    conda activate <my_env_name>

  6. Install python:

    conda install python --offline --use-local

  7. Install ArcGIS API for Python:

    conda install arcgis arcgis-mapping --offline --use-local

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:

Use dark colors for code blocksCopy
1
2
  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:

1.) Install the ArcGIS API for JavaScript locally.

  • Navigate to ArcGIS API for JavaScript SDK Downloads page here.
  • Download the v4.33 API for the API for Python 2.4.2 release.
  • Once the JavaScript API is downloaded, refer to the instructions in your_local_path/arcgis_js_v433_api/install.htmlto host the ArcGIS API JavaScript locally.

2.) After adding the mimetypes from the JavaScript installation instructions, you may have to add the following headers for JavaScript to work fully.

  • Access-Control-Allow-Credentials
  • Access-Control-Allow-Origin

3.) Set the JS_API_CDN environment variable to your local JavaScript installation:

Use dark colors for code blocksCopy
1
2
3
import os
CDN_Path = "http://<local_path>/arcgis_js_api/javascript/4.33/"
os.environ["JSAPI_CDN"] = CDN_Path

Pixi steps

Following are the steps to install the ArcGIS API for Python in a disconnected environment using pixi

1: Source Environment Setup

While in a connected environment, you'll need to download pixi and pixi-pack

  • Please follow this link on instructions on how to download and install pixi and pixi-pack into your connected environment:

After this, you will define your environment and package it into a portable executable.

Initialize the Project

  • Create a dedicated workspace and initialize Pixi.

    Use dark colors for code blocksCopy
    1
    2
    3
    mkdir arcgis
    cd arcgis
    pixi init

Configure the Manifest (pixi.toml)

  • Open the generated pixi.toml file and update it with the following configuration. This ensures the environment pulls from the Esri channel and targets multiple platforms.

  • pixi.toml

    Use dark colors for code blocksCopy
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    [workspace]
    authors = ["python@esri.com"]
    channels = ["esri", "main"]
    channel-priority = "disabled"
    name = "arcgis"
    platforms = ["win-64", "linux-64", "osx-arm64"] # you can include only the platforms you need
    version = "2.4.3"
    
    [dependencies]
    arcgis = "2.4.3.*"
    arcgis-mapping = "5.0.0.*"

Lock and Pack

  • Generate a lock file to ensure version consistency, then use pixi-pack to create a standalone installer script for Windows.

    Use dark colors for code blocksCopy
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    ## Resolve dependencies and lock versions
    
    pixi lock
    
    ## Create the portable installer
    
    ## You can create the installer for other platforms as well, by specifying the platform name `linux-64` or `osx-arm64`
    
    pixi-pack --platform win-64 --create-executable

2: Disconnected Environment Deployment

Follow these steps once you have moved the environment.ps1 file to your disconnected environment

Prepare the Installation Directory

Create a folder on your C: drive for creating the offline environment.

Use dark colors for code blocksCopy
1
2
3
mkdir C:\arcgis_offline

cd C:\arcgis_offline

Unpack the Environment

  • Copy environment.ps1 or environment.sh into the desired destination folder, then follow the platform specific instructions.
Windows
  • Execute the PowerShell script. This script will extract the Python interpreter and ArcGIS libraries, including necessary dependencies.

    Use dark colors for code blocksCopy
    1
    .\environment.ps1
Linux and macOS
  • Execute the shell script. This script will extract the Python interpreter and ArcGIS libraries, including necessary dependencies.
Use dark colors for code blocksCopy
1
./environment.sh

Activate the Environment

  • The unpacking process creates an env folder and an activate.bat file. To enter the environment:
Built-in Activation

The unpacked environment includes an activation script that can be used without the need to install Conda or Pixi standalone.

Windows
  • Type cmd to switch from PowerShell to the Command Prompt.

  • Run the activation script.

    Use dark colors for code blocksCopy
    1
    2
    3
    cmd
    cd C:\path\to\unzipped\env
    activate.bat
Linux and macOS

Run the activation script

Use dark colors for code blocksCopy
1
2
cd /path/to/unzipped/env
./activate.sh
Activating with Conda/Miniconda
Windows
Use dark colors for code blocksCopy
1
conda activate C:\path\to\unzipped\env
Linux and macOS
Use dark colors for code blocksCopy
1
conda activate /path/to/unzipped/env

3: Verification

  • Ensure the installation was successful and the paths are correctly mapped.

Verify the python path

  • Run the following command to confirm that the active Python is the one located within your arcgis_offline folder:
Windows
Use dark colors for code blocksCopy
1
2
where python
REM Expected output: C:\arcgis_offline\env\python.exe or similar
Linux and macOS
Use dark colors for code blocksCopy
1
2
which python
# Expected output: /path/to/arcgis_offline/env/python or similar

Verify Library Versions

  • Launch the Python interpreter and check the versions of the installed ArcGIS modules:
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
python
>>> import arcgis
>>> print(arcgis.__version__)
# Expected Output
2.4.3

>>> import arcgis.map
>>> print(arcgis.map.__version__)
# Expected Output
5.0.0
  • Verify any other functionality needed in your specific environment and workflows.

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