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. image

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)

Most upvoted comments

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?

image My vscode still works.

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:

conda list arcgis

jupyter labextension list

your arcgis version MUST match the jupyter extension version

I’m using arcgis api 2.1.0:

Known labextensions:
   app dir: C:\Users\me\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\share\jupyter\lab
        @jupyter-widgets/jupyterlab-manager v2.0.0 enabled  ok
        arcgis-map-ipywidget v2.1.0 enabled  ok

You might need to install the jupyter extension through terminal.

jupyter labextension install arcgis-map-ipywidget@2.1.0

Current error message indicates that VSCode can’t find the ESRI Map Widget. ESRI VSCode Error

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: image

jupyter lab path

You will see your jupyter lab path to extensions.

in summary:

  • Check your node version
  • Check your arcgis api version
  • Check your extensions version
  • Check your jupyter lab version, the default is 2.2.10 I wish you the best of luck! Let me know if it works for you.

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):

JupyterLab v3.4.8
C:\Users\firstname.lastname\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone-2\share\jupyter\labextensions
        jupyter-matplotlib v0.11.3 enabled ok
        jupyterlab-plotly v5.14.1 enabled ok
        jupyterlab_pygments v0.2.2 enabled ok (python, jupyterlab_pygments)
        @jupyter-widgets/jupyterlab-manager v5.0.7 enabled ok (python, jupyterlab_widgets)

Other labextensions (built into JupyterLab)
   app dir: C:\Users\firstname.lastname\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone-2\share\jupyter\lab
        arcgis-map-ipywidget v1.8.0 enabled ok


Build recommended, please run `jupyter lab build`:
    arcgis-map-ipywidget needs to be included in build

When trying to update the arcgis-map-widget jupyterlab extension, I get the following error message:

An error occurred.

ValueError:
"arcgis-map-ipywidget@2.1.0" is not compatible with the current JupyterLab
Conflicting Dependencies:
JupyterLab              Extension      Package
>=3.4.8 <3.5.0          >=2.0.0 <3.0.0 @jupyterlab/application
See the log file for details:  C:\Users\firstname.lastname\AppData\Local\Temp\jupyterlab-debug-5rdy3941.log

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 message

Collecting package metadata (current_repodata.json): done
Solving environment: /
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:

  - esri/win-64::arcgis==2.1.0.3=py39_10
  - esri/win-64::arcpy==3.1=py39_arcgispro_41759
  - esri/win-64::arcpy-base==3.1=py39_41759
  - defaults/win-64::bokeh==3.1.0=py39hd4e2768_0
  - defaults/win-64::bottleneck==1.3.5=py39h080aedc_0
  - esri/win-64::cftime==1.6.2=py39_0
  - defaults/win-64::contourpy==1.0.5=py39h59b6b97_0
  - defaults/noarch::dask==2022.2.1=pyhd3eb1b0_0
  - esri/win-64::gdal==3.4.0=arcgispro_py39_17150
  - esri/win-64::h5py==3.7.0=arcgispro_py39_0
  - esri/noarch::ipykernel==6.16.0=py_1
  - esri/noarch::ipython==7.34.0=pyhbfea036_1
  - esri/noarch::jupyterlab==3.4.8=py_0
  - esri/noarch::jupyterlab_server==2.16.0=py_1
  - esri/noarch::jupyter_client==6.1.12=py_0
  - esri/noarch::jupyter_console==6.4.2=py_0
  - esri/noarch::jupyter_contrib_core==0.4.0=py_0
  - esri/noarch::jupyter_contrib_nbextensions==0.6.0=py_2
  - esri/win-64::jupyter_core==4.11.2=py39_0
  - esri/noarch::jupyter_highlight_selected_word==0.2.0=py_4
  - esri/noarch::jupyter_latex_envs==1.4.6=py_5
  - esri/noarch::jupyter_nbextensions_configurator==0.4.1=py_3
  - esri/noarch::jupyter_server==1.21.0=py_0
  - esri/noarch::lerc==4.0=pyh39e3cac_0
  - esri/win-64::matplotlib==3.6.0=py39_arcgispro_3
  - defaults/win-64::matplotlib-inline==0.1.6=py39haa95532_0
  - esri/win-64::mkl_fft==1.3.0=py39_0
  - esri/win-64::mkl_random==1.2.2=py39_0
  - esri/noarch::nbclassic==0.4.8=py_0
  - esri/noarch::nbclient==0.7.0=py_3
  - esri/noarch::nbconvert==7.2.1=py_2
  - esri/noarch::nbformat==5.6.1=py_0
  - esri/win-64::netcdf4==1.6.1=py39_arcgispro_1
  - esri/noarch::notebook==6.4.12=py_0
  - esri/noarch::notebook-shim==0.1.0=py_0
  - esri/win-64::numexpr==2.8.1=py39_0
  - esri/win-64::numpy==1.20.1=py39_0
  - defaults/win-64::pandas==1.4.4=py39hd77b12b_0
  - esri/win-64::pro_notebook_integration==3.1=py39_12
  - esri/noarch::saspy==4.3.2=py_1
  - esri/win-64::scipy==1.6.2=py39_0
  - defaults/win-64::seaborn==0.12.1=py39haa95532_0
  - esri/noarch::stack_data==0.5.1=py_0
  - esri/win-64::swat==1.12.0=py39_0
  - defaults/win-64::terminado==0.17.1=py39haa95532_0
  - defaults/win-64::xarray==2022.11.0=py39haa95532_0
done

## Package Plan ##

  environment location: C:\Users\firstname.lastname\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone-2

  added / updated specs:
    - jupyterlab


The following NEW packages will be INSTALLED:

  executing          pkgs/main/noarch::executing-0.8.3-pyhd3eb1b0_0
  ipywidgets         esri/noarch::ipywidgets-7.7.2-py_0
  jupyterlab_widgets esri/noarch::jupyterlab_widgets-3.0.3-py_1
  matplotlib-base    esri/win-64::matplotlib-base-3.6.0-py39_arcgispro_4
  numpy-base         esri/win-64::numpy-base-1.20.1-py39_0
  pywinpty           esri/win-64::pywinpty-2.0.1-py39_0
  traitlets          esri/noarch::traitlets-5.5.0-py_0
  widgetsnbextension esri/noarch::widgetsnbextension-3.6.1-py_0


Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Retrieving notices: ...working... done

But 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 ran https://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:

conda create --name myenvname
conda activate myenvname
conda install -c esri arcgis=1.7

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:

jupyter nbextension install --py --sys-prefix arcgis
jupyter nbextension enable --py --sys-prefix arcgis

I do not use VS Code to work with notebooks, but it should enable it on the environment if it is installed correctly.