Import module error

I am trying to import a client side module used for navigation and get this error.The module name is navigation.

ValueError: Attempted relative import beyond toplevel package at [navigation, line 6](javascript:void(0)) called from [Homeform, line 13](javascript:void(0))

The error is called from line 13 which is, from …import navigation

from …import navigation
class Homeform(HomeformTemplate):
def init(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)

# Any code you write here will run when the form opens.

navigation.go_home()

Thanks in advance for any help
def Home_click(self, **event_args):

You will have to provide a clone link for that. It happens because every form needs different code for importing. Some requires two dots, some one and some three. Don’t know the logic behind it though.

The dots are indeed kinda inscrutable, I would just let the auto complete guide your import. If that fails try 0-3 dots before the from statement until it works

1 Like

Thank you so much I appreciate your feedback

Thanks Duncan
I appreciate your feedback

1 Like

I am trying to import navigation module into homeform but get an import error no module named navigation
I have changed the dots from 0 to 3 tosee if that solves the error but no joy.
There is a client module navigation

any help will be amazing
thanks in advance
Wayne

Can you please share a clone link

I am new to all of this
please could you elaborate ‘clone link’?

There’s a section in the docs that shows how to get a clone link: Anvil Docs | Cloning Apps

@waynedavidstokes Did you figure out how to solve the import problem?
The accepted solution does not really answer the original question in this thread.

1 Like

The question in the subject is very broad and the solution to the original question is unlikely to help you.

Please ask a new question and add a few details about your specific case.

And welcome to the forum!

2 Likes

Thanks!
I have found the solution to my problem to another thread.
I assume the original poster was also following the anvil tutorial from TalkPython and got stuck on the issue that one of the imports was not working as it was a circular import problem.

I am leaving this comment and this link here Error while importing server module should anyone land on this thread via Google Search. (like I did originally)

1 Like

I am following the TalkPython Tutorial but following what you say on this post doesn’t really solve my problem. Please can you tell me exactly what you did? I am completely blocked with: <ValueError: Attempted relative import beyond toplevel package< !

Please reply as soon as possible. I really want to move on. :sneezing_face:

You have too many dots in your import. Let the autocomplete help you work out what the import should be, don’t just type in what the tutorial shows you for the import.

1 Like

Was it also the navigation module from the tutorial that is giving you problems?
What I did was similar to this answer (as I found on another thread),