arcgis-python-api: Visual Studio Code not showing maps with Python 3.8
Describe the bug
Trying to show a map inside jupyter notebook in Visual Studio Code when using a new conda environment (not the one from ArcGIS Pro) .
The map shows an unhandled error.
To Reproduce Steps to reproduce the behavior:
create a new conda env as described here: https://support.esri.com/en/technical-article/000022005
Write code in jupyter:
from arcgis import GIS
gis = GIS(url='https://<abc>.maps.arcgis.com',username='<username>',password='<pwd>')
mymap=gis.map('Zurich')
mymap
error
Messages in the console (browser console inside VS Code)
[Embedded Page] WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:1.2.0
webviewElement.ts:90 [Embedded Page] require promise
webviewElement.ts:90 [Embedded Page] WidgetManager: Loading class ArcGISMapIPyWidgetModel:arcgis-map-ipywidget:1.8.4
webviewElement.ts:90 [Embedded Page] Fetch IPyWidget source for arcgis-map-ipywidget
webviewElement.ts:90 [Embedded Page] require promise
webviewElement.ts:90 [Embedded Page] WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:1.2.0
webviewElement.ts:90 [Embedded Page] require promise
webviewElement.ts:90 [Embedded Page] WidgetManager: Loading class ArcGISMapIPyWidgetModel:arcgis-map-ipywidget:1.8.4
webviewElement.ts:90 [Embedded Page] Fetch IPyWidget source for arcgis-map-ipywidget
webviewElement.ts:90 [Embedded Page] require promise
webviewElement.ts:90 [Embedded Page] WidgetManager: Loading class ArcGISMapIPyWidgetView:arcgis-map-ipywidget:1.8.4
webviewElement.ts:90 [Embedded Page] Fetch IPyWidget source for arcgis-map-ipywidget
webviewElement.ts:90 [Embedded Page] require promise
webviewElement.ts:90 [Embedded Page] WidgetManager: Loading class LayoutView:@jupyter-widgets/base:1.2.0
webviewElement.ts:90 [Embedded Page] require promise
webviewElement.ts:90 [Embedded Page] Error on render:
webviewElement.ts:90 [Embedded Page] Error: Script error for "esri/Map"
https://requirejs.org/docs/errors.html#scripterror
Platform (please complete the following information):
- OS: windows 10
- Visual Studio Code (latest with python and jupyter extension from microsoft)
- Python API Version [
1.8.4
] - Python 3.8
Additional context
- The same code runs without problems in condas jupyter notebook
- The same code also runs in VS Code when using the conda environment installed with ArcGIS Pro
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (2 by maintainers)
Hi @SCMGeocom and @nam-tonthat Map widget display of ArcGIS API for Python is not supported in VS code. Please try jupyter notebooks when it comes to drawing or plotting in maps. Thanks!
Thirded. I know that VS Code can be a bit troublesome to support but it is now a go-to all-purpose IDE for a massive amount of the developer community.
Just want to second the support for maps in VS Code
ESRI claims that here that quote: “ArcGIS API for Python can be used from any application that can execute Python code. You can use the API from any of your favorite IDEs such as PyCharm, MS Visual Studio, Eclipse, Spyder, Rodeo, IDLE, etc.”
So I ask, why does ESRI not “support” the use of notebook mapping functionality in VS code then? They clearly encourage the use of these IDEs in the aforementioned documentation. We should not need to jump through these complicated hoops like manually installing nodeJS or jupyter extensions.
Given that this is an expensive piece of software, I think this basic functionality is required in popular IDEs…
This is an incredibly frustrating problem and something that is easy to do in alternatives like geopandas, so why is it like pulling teeth in arcpy?
Env: windows 10:
To ensure that your VS Code setup works correctly on Windows 10, I would follow these steps:
Install Node.js manually on your PC. Make sure to install Node.js version 14.6.0. You can download it from the official Node.js website and follow the installation instructions.
Open your command prompt or terminal and run the following command to check the version of ArcGIS installed:
your arcgis version MUST match the jupyter extension version
I’m using arcgis api 2.1.0:
You might need to install the jupyter extension through terminal.
Current error message indicates that VSCode can’t find the ESRI Map Widget.
https://anaconda.org/esri/arcgis for current versions.
Test code from arcgis.gis import GIS gis = GIS() map = gis.map() map
I recommend checking your system as your log indicates [LabBuildApp] Node v18.15.0.
According to the documentation, the implementation requires Node.js version 14.6.0. Have you considered downgrading your Node.js version to meet the requirement?
Additionally, it appears that your system has “arcgis-map-ipywidget@2.1.0” installed in Node v18, which might not be compatible with ArcGIS API 2.8. You can try using npm from the terminal to verify this as well.
To determine your JupyterLab path to extensions, please follow these steps in the Python Command Prompt:
You will see your jupyter lab path to extensions.
in summary:
I get the exact same error message in VS code as @app-EL and showing maps worked for just a couple of months ago for me.
@hildermesmedeiros This is how it looks like for me (running
jupyter labextension list
from Python Command Prompt):When trying to update the arcgis-map-widget jupyterlab extension, I get the following error message:
The log file: jupyterlab-debug-5rdy3941.log
My version of JupyterLab seems to be compatible, still I updated it via
conda update jupyterlab
and I get the following interesting messageBut that does not help unfortunately. Also my jupyterlab build does not succeed, log file: jupyterlab-debug-ouv27jzf.log
In both cases, webpack seems to be involved. Then I realized that I had python-webpack installed, an unmaintained package (webpack 6.0.0 whereas the latest release of webpack.js.org is 5.83.1. So I just uninstalled it with pip (didn’t work with conda for some reason)
pip uninstall webpack
and ranhttps://github.com/webpack/webpack
from Python Command Prompt.No better luck so far, to be continued…
We found that the version 1.7 of arcgis works with VS code. We created a new conda environment and installed arcgis 1.7 there:
we have no idea of what is the compatible version of arcpy though. Any idea of how to get to know that?
If the map isn’t showing in your clone environment, try this:
I do not use VS Code to work with notebooks, but it should enable it on the environment if it is installed correctly.