Import Client Module Error - AttributeError: ‘module’ object has no attribute - Talk Python

Welcome, @paddy10tellys, to Anvil’s Q&A forum.

Yup. I’ve had similar issues trying to install and use Eclipse and its ecosystem. It is very frustrating to follow instructions, verbatim, and fail. At first it seems like our own fault. Only later do we discover that the tool has far outpaced its documentation and examples.

How it gets that way is, alas, understandable. As someone who has written extensive documentation, it is very frustrating to hear higher-ups say “don’t bother working on docs or tutorials. You’re the only person on the planet who actually reads that stuff. Features are the priority. Those are things that real people will use.” (That isn’t happening to me anymore, but if it does, I’ll show them this thread.) Man-hours are always limited, and so priorities will always be in some conflict or other.

As for Python’s circular imports, I’ve been bitten quite a few times. Strictly speaking, it’s my own fault, but they are trivially easy to create, produce no warnings whatsoever, and most of the time, they just work anyway. The main problem is, when they don’t, there is often no immediately obvious solution.

The general guideline – which works more often in Python libraries and programs than in Python scripts – is to never use from ... import. While that gives much-superior documentation to the program – it makes usage explicit – unfortunately that syntax also makes the code much more vulnerable to circularity issues. Workaround: use plain import instead.

That doesn’t prevent circular imports in the first place, though. I’ve never heard of any algorithm that would help developers prevent them, or help refactor them once they turn problematic. (If there was, someone would probably have turned it into a tool by now.)

2 Likes