English

Bug: Fix for HTTPS/HSTS enforcement in ArcGIS Online Jupyter Notebooks

Description

The MapView widget fails to display in Jupyter Notebooks hosted within ArcGIS Pro when run inside a Jupyter Notebook. The ArcGIS API for Python has an interactive map widget that allows visualization of maps, spatial data, and more. This map widget is normally created via gis.map() , arcgis.widgets.MapView(), and arcgis.mapping.WebMap().

When running a Jupyter Notebook on a computer over http, the interactive map widget fails to load properly in some browsers. This map widget loads the ArcGIS API for JavaScript from js.arcgis.com, which recently enforced HSTS standards (HTTPS only). BUG-000136038 is associated with this issue.

The image below shows the Jupyter Notebook MapView() widget displaying an error in ArcGIS Pro.

Image of the Jupyter Notebook MapView widget displaying an error in ArcGIS Pro

Cause

The Python API for Python redirects to an HTTP URL that no longer functions after the update.

Workaround

If errors such as that described above are encountered, update the ArcGIS API for Python to version 1.8.4. This version contains the fix for the map widget not drawing.

To upgrade the arcgis package using Python Package Manager:

  1. Open ArcGIS Pro with a new blank Project.
  2. Select the Project tab to access the Pro backstage, as shown in the screenshot below.
  3. Select the Python menu option.
  4. Use the Project Environment Manage Environments option and Clone the default.
  5. Once it is cloned, select the appropriate environment and relaunch Pro.
  6. Return to the Python menu and select the Update Packages option.
  7. Choose the appropriate arcgis release from the list of packages with recent updates or select Update All.

Python Project environment showing list of packages

  1. Refresh the Installed Packages to verify that version 1.8.4 is installed:Python Project environment refreshed showing package versions

The map widget now displays:

map widget in a notebook

Note:
In previous versions of this article, and prior to updating the arcgis API, Esri suggested a couple of workarounds to make sure widgets draw. If you used one of the previous workarounds, make sure to undo these:
  • If you were using the arcgis API at version 1.8.1 or greater, and previously set the environment variable JSAPI_CDN to https://js.arcgis.com/4.15/, make sure you remove this variable.
  • If you set the environment variable at the head of your notebook with the below code, make sure to delete it.
import os
os environ['JSAPI_CDN'] = 'https://js.arcgis.com/4.15/'
  • If you added a JSAPI_CDN variable to your system or user Environment Variables using Windows System Properties, delete the variable.
  • If you were using the arcgis API at version 1.5.0 through 1.8.0, and set the MapView js_cdn property to https://js.arcgis.com/4.15/ with the code below, make sure to delete it.
from arcgis.widgets 
import MapView
MapView.set_js_cdn('https://js.arcgis.com/4.15/')

Note on older versions of the Python API

Different versions of the Python API target different JS API versions. If running on an older version of Python API, set the JS API CDN to the correct version. Use the table below for reference. The following script displays the Python API version installed:

import arcgis
arcgis.__version__
Python API VersionJS API Version
1.8.44.15
1.8.34.15
1.8.24.15
1.8.14.15
1.8.04.14
1.7.14.13
1.7.04.13
1.6.24.11
1.6.14.11
1.6.04.10
1.5.24.9
1.5.14.8
1.5.04.8

Related Information

Last Published : 2/10/2021

Article ID: 000024831

Software: ArcGIS API for Python 1.8.4, 1.8.3, 1.8.2, 1.8.1, 1.8.0, 1.7.1, 1.7.0, 1.6.1, 1.6, 1.5.3, 1.5.2, 1.5.1, 1.5, 1.4.1, 1.4, 1.3, 1.2.4, 1.2.3, 1.2.2, 1.2.1, 1.2, 1.0.1, 1.0