Select to view content in your preferred language

No module named 'notebook.notebookapp'

1333
7
10-08-2024 10:10 AM
RogerAsbury
Frequent Contributor

I have, what I'm assuming is a pretty basic function, mostly pulled from an esri tutorial. However, it's running on an Azure function app in Python. The function below errors on that server with the following:

2024-10-08T00:46:12Z [Warning] MapView class replaced with a non-functional placeholder due to the following import error:
2024-10-08T00:46:12Z [Error] Error retrieving map: No module named 'notebook.notebookapp'
 
I am including the arcgis python library in the code, and I've done plenty of Python coding with it in the past, but I've never run across this error before. The code that causes this is below. Any ideas?
 

 

def GetMap():
    gis = GIS(url, user, passwd)
    try:
        map = gis.map()
        map.basemap = "arcgis-streets"
        map.center = [34.027, -118.805]
        map.zoom = 12
        return map
    except Exception as e: 
        logging.error(f"Error retrieving map: {e}")

 

--
Roger Asbury
Analyst/Programmer - Fairbanks North Star Borough
Tags (2)
0 Kudos
7 Replies
BijanTaheri
Occasional Contributor

Hi,

I ran your code in a new ArcGIS Notebook in Pro, and it worked fine. I'm on ArcGIS Pro 3.3.1 and ArcGIS API for Python 2.4.0. What versions of python/arcgis api for python are you working with?
The code if very simple and should work without problems, maybe it is the rest your code that tries to use the notebook.notebookapp module?

BijanTaheri_0-1728555581933.png

 

RogerAsbury
Frequent Contributor

Edit: I updated the arcgis python library and the error went away with the below code. However, I added a layer check and the notebook error came back, so still confused:

for layer in wm.layers:
    if layer.id == "Parcels_Taxroll_1278":
        results = "YEAH!"
return results 

 

The issue seems to be that I'm not doing this in an ArcGIS Notebook, but trying to run from an Azure Function Application server.

I tried this another way, with the following code, and while it does the gis.content.get() just fine, as soon as I add the call to WebMap(), I receive the same error.

 

 

 

def GetMap(pan):
    gis = GIS(url, user, passwd)
    try:
        wmItem = gis.content.get('6dbe1de76e3e4848a6d92230ec29c3b3')            
        wm = WebMap(wmItem)
    except Exception as e: 
        logging.error(f"Error retrieving map: {e}")

 

 

 

 

--
Roger Asbury
Analyst/Programmer - Fairbanks North Star Borough
0 Kudos
Clubdebambos
MVP Regular Contributor

Hi @RogerAsbury 

If you updated to ArcGIS API Version 2.4.0 the WebMap class is gone and is now Map.

## 2.3.0 and lower
from arcgis.mapping import WebMap

## 2.4.0
from arcgis.map import Map

 

This also has other implications as accessing WebMap layers has also changed with the content property. Check out the updates here

~ learn.finaldraftmapping.com
0 Kudos
RogerAsbury
Frequent Contributor

It looks like I currently have 2.3.1 installed. When I try to upgrade I get the following error message:

pip install arcgis==2.4.0
ERROR: Ignored the following yanked versions: 1.8.5.post1, 1.8.5.post2
ERROR: Ignored the following versions that require a different python version: 2.4.0 Requires-Python <3.13,>=3.10
ERROR: Could not find a version that satisfies the requirement arcgis==2.4.0 (from versions: 1.3.0, 1.3.0.post1, 1.3.0.post2, 1.4.0, 1.4.1, 1.4.2, 1.5.0, 1.5.1, 1.5.2, 1.5.2.post1, 1.5.3, 1.6.0, 1.6.1, 1.6.1.post1, 1.6.2, 1.6.2.post1, 1.7.0, 1.7.1, 1.8.0, 1.8.0.post1, 1.8.1, 1.8.2, 1.8.3, 1.8.3.post1, 1.8.3.post2, 1.8.4, 1.8.5.post3, 1.9.0, 1.9.1, 2.0.0, 2.0.1, 2.1.0, 2.1.0.1, 2.1.0.2, 2.1.0.3, 2.1.0.4, 2.1.0.5, 2.2.0, 2.2.0.1, 2.2.0.2, 2.2.0.3, 2.2.0.4, 2.3.0, 2.3.0.1, 2.3.0.2, 2.3.0.3, 2.3.1)
ERROR: No matching distribution found for arcgis==2.4.0

--
Roger Asbury
Analyst/Programmer - Fairbanks North Star Borough
0 Kudos
RogerAsbury
Frequent Contributor

I'm gonna update this because it has now been two weeks of severe annoyance and zero real progress. I'm hoping someone more familiar with these things than myself strolls in here. 🙂

1. The no matching distribution found error went away after I upgraded my local version of Python to 3.11.

2. However, this would then stall when the deploy from VS Code got to the section "Running pip install", eventually timing out without error.

3. This was solved by creating a ci/cd pipeline in Github to autodeploy on a new code push.

4. This seemed to properly build and deploy to the server, but the server seems to think it doesn't have a function app, per the attached image.

funcapp-notthere.png

5. The code is there, so I have no idea why it isn't running. Server response is a 404 error.

funcapp-code.png

So, still no idea what's going on, or why things aren't working...

Edit to add - If I run it locally from VS Code, this function works as expected, for what it's worth.

--
Roger Asbury
Analyst/Programmer - Fairbanks North Star Borough
0 Kudos
RogerAsbury
Frequent Contributor

Soooo, after more testing today, I can say the following:

1. Commenting out "from utilities import report" and any associated calls to report, allows the function to be seen by the function server and run, though obviously not do much.

2. Adding "import requests" immediately sends it back into a 404 status, even if I don't utilize the requests library. If I do, say to make a simple call to a website, it still 404s.

3. These were not issues when utilizing the older version of Python and Azure V1 function app model. Though obviously the original error existed...

--
Roger Asbury
Analyst/Programmer - Fairbanks North Star Borough
0 Kudos
RogerAsbury
Frequent Contributor

This is my last update on this because it's pretty clear this is no longer an ArcGIS sdk issue, and more an issue with Azure and Github CI/CD. While I no longer have the original error, the move to a more current version of Python, and the subsequent need to move to Azure's V2 function app model, still has my app broken.

If you find yourself in a similar situation, you can find more information at the following links:
Exception: ModuleNotFoundError: No module named 'requests' · Issue #627 · Azure/azure-functions-pyth...

How to properly install python modules with venv using DevOps Pipeline build? Module Not Found Error...

Azure function python v2 with external packages HTTP Trigger not visible in Azure Portal after deplo...

--
Roger Asbury
Analyst/Programmer - Fairbanks North Star Borough
0 Kudos