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)
- Windows 64-bit (
-
If your source (connected) environment is a different platform than your target platform:
-
Set the
CONDAenvironment variable to your target (disconnected) platform, either_SUBDIR win-64,linux-64, orosx-64. For example:- Bash:
export CONDA_SUBDI R=win-64 - PowerShell:
$env:CONDA _SUBDI R="linux-64" - cmd:
set CONDA_SUBDI R=linux-64
- Bash:
-
-
Create an empty directory for downloads, for example:
- Windows:
mkdir C:\ Users\me\ Downloads\arcgis _offline - macOS:
mkdir ~/Downloads/arcgis _offline
- Windows:
-
Set the
CONDAenvironment variable to your empty download directory from the previous step. For example:_PKGS _DIRS - Bash:
export CONDA_PKGS _DIR S=~/ Downloads/arcgis _offline - PowerShell:
$env:CONDA _PKGS _DIR S=" C :\ Users\me\ Downloads\arcgis _offline" - cmd:
set CONDA_PKGS _DIR S= C :\ Users\me\ Downloads\arcgis _offline
- Bash:
-
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:
CondaExit Zero : Package caches prepared. Unlink Link Transaction 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
-
Configure Anaconda for offline use. See Conda Configuration for full details:
conda config --set offline True -
Obtain the package cache directories in your disconnected environment
conda config --show pkgs_dirs -
Copy the files from your connected environment to one of the cache directories specified in the previous step.
-
Create a new empty environment:
conda create -n <my_env _name > -
Activate the environment:
conda activate <my_env _name > -
Install python:
conda install python --offline --use-local -
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:
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
yourto host the ArcGIS API JavaScript locally._local _path/arcgis _js _v433 _api/install.html
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 environment variable to your local JavaScript installation:
import os
CDN_Path = "http://<local_path>/arcgis_js_api/javascript/4.33/"
os.environ["JSAPI_CDN"] = CDN_PathPixi 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 blocks Copy 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 blocks Copy [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 blocks Copy ## 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.
mkdir C:\arcgis_offline
cd C:\arcgis_offlineUnpack 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 blocks Copy .\environment.ps1
Linux and macOS
- Execute the shell script. This script will extract the Python interpreter and ArcGIS libraries, including necessary dependencies.
./environment.shActivate 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 blocks Copy cmd cd C:\path\to\unzipped\env activate.bat
Linux and macOS
Run the activation script
cd /path/to/unzipped/env
./activate.shActivating with Conda/Miniconda
Windows
conda activate C:\path\to\unzipped\envLinux and macOS
conda activate /path/to/unzipped/env3: 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
where python
REM Expected output: C:\arcgis_offline\env\python.exe or similarLinux and macOS
which python
# Expected output: /path/to/arcgis_offline/env/python or similarVerify Library Versions
- Launch the Python interpreter and check the versions of the installed ArcGIS modules:
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.