Bug: Fix for HTTPS/HSTS enforcement in ArcGIS Online Jupyter Notebooks
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().
The image below shows the Jupyter Notebook MapView() widget displaying an error in ArcGIS Pro.
The Python API for Python redirects to an HTTP URL that no longer functions after the update.
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:
- Open ArcGIS Pro with a new blank Project.
- Select the Project tab to access the Pro backstage, as shown in the screenshot below.
- Select the Python menu option.
- Use the Project Environment Manage Environments option and Clone the default.
- Once it is cloned, select the appropriate environment and relaunch Pro.
- Return to the Python menu and select the Update Packages option.
- Choose the appropriate arcgis release from the list of packages with recent updates or select Update All.
- Refresh the Installed Packages to verify that version 1.8.4 is installed:
The map widget now displays:
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 Version||JS API Version|
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