[Fixed] No package functool when importing anvil_extras routing

Sometimes my app prints error messages in some of my users’ sessions:

ModuleNotFoundError: No module named 'functools'
at app/anvil_extras/routing/_navigation.py, line 8
called from app/anvil_extras/routing/__init__.py, line 12
called from MainApp, line 5

At MainApp line 5, it’s trying to import routing from anvil_extras

from anvil_extras import routing

anvil_extras is set to the published version.

I can’t reproduce it on my side. Does anyone have ideas what is the cause?

Thanks for the bug report. We’ve not seen this one before.

Have any users reported it directly to you? Would be great to have some reproduction steps.

If you want a workaround you could try importing functools in a startup module.
That way it’ll be in the python module cache already.

No, my users did not report it to me. I do an error log search every day and found it happened twice already. Unfortunately, I couldn’t get the user info since the app failed at the beginning. I can’t reproduce it either.

Thanks for the tip.

1 Like

Let us know if it persists, any additional logging you could do would also be helpful.

Logging the browser information might be handy incase it’s browser specific.

from anvil.js.window import navigator
print("Browser Info:", navigator.userAgent)
1 Like

It happens again. Adding import functools and the browser info. Let’s see if I can get more info about this bug.
image

1 Like

Is there any chance you might have used ‘functools’ as the name for some other object somewhere in your code?

no, I don’t have functools as the name of an object but I have from functools import reduce in another file.

Oh well, it was worth checking!

I just found the same error in my logs:

Any news to this bug?

Same here, but only for some users.

image

In this specific case, I know the user uses a Mac Book.

We are also seeing this same error but not consistently. I have added the print statement above and will report back when we see something.

So I have added the print statement and this is userAgent data that came back…

Browser Info: Mozilla/5.0 (iPhone; CPU iPhone OS 16_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/264.0.531249063 Mobile/20E772520a Safari/604.1
ModuleNotFoundError: No module named 'functools'
at app/anvil_extras/routing/_navigation.py, line 8
called from app/anvil_extras/routing/__init__.py, line 12
called from MainForm, line 7

Hi,

Was this bug fixed? I’m getting the same error after upgrading anvil-app-server to v1.9.0. it was working fine with app-server v1.8.0

here is the logged error
image

Same here–we’re also seeing this error message randomly. Using release v 2.2.0

Same here. It appears that downgrading the Anvil App server from version 1.10.1 to 1.8.0 has rectified the problem.

image

@y.yamazaki see this thread:

Thank you for your response. However, upon upgrading our app server from version 1.8.0 to version 1.10.1, I encountered the issue. It appeared that our users were unsure how to correct the error and were unaware that refreshing their browser cache could prove beneficial. As a result, I was compelled to revert back from version 1.10.1 to 1.8.0.

1 Like