Use the ArcGIS API for Python in a disconnected environment.
Steps
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
CONDA
environment 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
CONDA
environment 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 -
You may see a message:
Conda
Exit 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 --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.30 API for the API for Python 2.4.0 release.
- Once the JavaScript API is downloaded, refer to the instructions in
your
to host the ArcGIS API JavaScript locally._local _path/arcgis _js _v430 _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.30/"
os.environ["JSAPI_CDN"] = CDN_Path