Test your install with jupyter notebook - map widget doesn't display

3171
18
10-09-2018 07:52 AM
NicoleBradstreet1
New Contributor II

I just installed the ArcGIS API for Python and I'm having an issue displaying a map widget in jupyter notebook.  I think it has something to do with my install, a version issue, or a missing extension?  Here's a screen shot.  Any suggestions?

-Nicole

Here is a little more detail about my install:

0 Kudos
18 Replies
DanPatterson_Retired
MVP Esteemed Contributor

launched from my environment (not a clone, however).

What did it say in your console? was there an error? you do have the package installed, and did you run it from the clone?

0 Kudos
NicoleBradstreet1
New Contributor II

Here are some screen shots.  I did get an error when I tried to load a map,

Partial list of packages:

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

the error is related to a geocoder error.  were you trying to map the location of the 'user'

0 Kudos
NicoleBradstreet1
New Contributor II

I was just following the steps from the python guide - Using the GIS.  Whether I try to load a map as an anonymous user or from my content I'm having no success.  I'm confused about the geocoder error, I'm not attempting to geocode anything.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

hmmm

One of my demos.... and the message I get because I didn't save the widget sate with the notebook... no sweat... I just run the cell

And when you run the cell, in this case I put in coordinates and a zoom level because I wanted to visit the birthplace of GIS (home of Roger Tomlinson... check your gis history)

Then I wanted to do a search, pour moi, to see if I could find some content at this locale...

And it returned some hits, but of course I needed some python code to demonstrate so I through in some conditions on how to display it.

And it carries on from there

and in *.py form (had issues with notebook export)

# coding: utf-8

# ## Jupyter Notebook for map demos##
# 
# ### To Begin... ###
# 
# Login arcgis online using your account or an anonymous login (see References section).
# The map is centred on Carleton University, Ottawa, Canada.  It may take some time to load so be patient.  
# The coordinates are given in Latitude, Longitude by convention.  Just remember this, since coordinates within
 a GIS follow the mathematical ordering of Longitude, Latitude (aka X,Y ordering).

# In[2]:


from arcgis.gis import GIS
gis = GIS()
gis.map((45.381298, -75.697823), zoomlevel=14)  # Loeb Bldg at Carleton U


# Search for something within the area... In this case, I am going to look for some of my code samples to see if
 anything shows up through our portal.

# In[2]:


srch_for = "Dan Patterson"
items = gis.content.search(srch_for, item_type="Code Sample")
n = len(items)
#
# other examples... item_type: "Code sample", "Web Map", "Geoprocessing sample", "Feature layer"
print("There were {} items found using '{}' as keyword...showing the first".format(n, srch_for))

if n == 2:               # use this to display the first
    display(items[0])
elif n > 2:
    for item in items:   # use this block to display all
        display(item)


# ### __References:__##
# 
# **Login options:**
# 
#     https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/
#     
#     anonymous  - gis = GIS()
#     
#     within Pro - gis = GIS("pro")  # note, Pro must be running when you do this.
#     
# **Testing the basics:**
# 
#     https://developers.arcgis.com/python/guide/install-and-set-up/#Install-using-Conda
#     
#     

# There... wasn't that easy.
NicoleBradstreet1
New Contributor II

I copied your demo (thanks!) and ran the cell twice - still no luck.    I was able to pull your items though!  I will keep digging until I find a solution and will post it when I do.  

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

well at least you have some tools you can use in the interim

simoxu
by MVP Regular Contributor
MVP Regular Contributor

Looks like the Map widget is not enabled.

Firstly, try this in the exact environment (if you have multiple envs) your jupyter server is running in:

python -m arcgis.install

If it does not work, then you can check if the map widget is enabled in notebook:

jupyter nbextension list

if not, enable it manually:

jupyter nbextension enable --py --sys-prefix widgetsnbextension

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

Last, you can check your environment to see if it meets the minimal system requirement:

print("python version: ",sys.version)
print("arcgis API version: ",arcgis.__version__)
print("widgetnbextension: ",widgetsnbextension.__version__)
print("ipywidgets version: ",ipywidgets.__version__)

Hope this helps.

DanPatterson_Retired
MVP Esteemed Contributor

good point, assumed it would be if installed (mine was)

0 Kudos