Quick question: why is Python crying wolf when it comes to importing modules?
I get the following error:
Traceback (most recent call last):
File "c:\Users\xxx\OneDrive - xxxLtd\xxx\support\views.py", line 5, in <module>
from <MODULE> import utils
ModuleNotFoundError: No module named '<MODULE>'
except it has no problem importing any of the methods from the - which is great, except when I want to run a file for debugging purposes, it wont allow me to continue because it’s returning a non-existent error.
Clearly, that module is not accessible in the way you are executing it. Python isn’t “crying wolf”[1], it actually can’t find that module and therefore can’t import the functions.
Why? IDK, you did not provide a reproducible example or even enough information to guess what the issue is.
A wild guess is you are running the code from a different working directory, which means that <MODULE> is not being found.
Which btw is also a complete misuse of that phrase, but ok ↩︎
There two outcomes to this, its either accessible, or inaccessible.
Just like a garden, its either accessible or its inaccessible.
Its the equivalent to going through the garden gate and getting a ball, then bringing that back out of the garden. The garden is apparently inaccessible yet I successfully managed to retrieves the ball from said garden.
Yes, it’s from a different working directory, however there is clearly no problem as I am successfully accessing the methods from the module, so it’s contradicting itself. There’s no “clearly” about it, it’s as clear as mud. If it can’t find the module then how can it successfully access the methods?
How are you running a file for debugging purposes?
You’re saying that you’re doing two different things, and one isn’t working. Can you share more information about the two methods and what’s happening?
There’s a few reasons why this might occur, such as virtual environments or different python versions. For example, let’s say you’re trying to debug through VScode, but normally running through Terminal, you might have two different interpreters involved. But, we need more info.
I’m really guessing here, since there really is not enough information, but…
Did you mean that you get auto-complete results for method names when saying you can “successfully access the methods”?
If so, then that’s your editor doing that, not Python. It may show incorrect suggestions on what can be imported depending on on how it’s configured and where it’s open, which may differ from how and where you’re running your code from.