"ImportError: No module named" errror

I have a module named globals_ in my current application which is referenced by some forms and it works as intended when I “import globals_” in these forms

I created a new form and included “import globals_” and I receive the import error message.

what am I missing?
Thanks

Have you recently upgraded to Python 3?
Not that I am an expert but I have read that python 3 requires an explicit import.

https://anvil.works/forum/t/organising-big-apps-and-python-3-in-the-browser/3883?u=rickhurlbatt

2 Likes

yes- this was after the upgrade to 3. I have reverted back to 2 and its working.
Thanks

1 Like

Please is there a way this module importation can be done with python 3?

As has been mentioned, python 3 requires an explicit import. See the anvil docs here:-

https://anvil.works/docs/how-to/migrating-to-client-side-python-3#make-all-imports-explicit

I looked through the content of this and I tried it out and it didn’t work.

Can you send a screen shot of the navigation panel or a share link to your app or some code snippets?
You need to add some code like

from ..Globals_ import Globals_

I am not sure about whether the _ will cause issues though. I will test now.

Also try typing from and then pressing tab to bring up the auto completer to select the right import statement

See this post as I think it is related or may be the same issue:

2 Likes