You have mutual top-level imports, which is almost always a bad idea.

If you really must have mutual imports in Python, the way to do it is to import them within a function:

# In b.py:
def cause_a_to_do_something():
    import a
    a.do_something()

Now a.py can safely do import b without causing problems.

(At first glance it might appear that cause_a_to_do_something() would be hugely inefficient because it does an import every time you call it, but in fact the import work only gets done the first time. The second and subsequent times you import a module, it's a quick operation.)

Answer from RichieHindle on Stack Overflow
Discussions

"Module ... has no attribute ..."
The thing with imports is they are relative to the "working directory". And that directory is decided by the IDE (vscode). It could be a directory that you don't expect, and it could be loading something else instead of what you want. So do 3 things to check what goes wrong. 1 - Add code to the start of converters.py to make sure it gets loaded, and print its path print("converters is loaded") print(__file__) def lbstokg(...): ... ... 2 - Add code to the start of main, to figure out the current working directory, and list files there. import os print(os.getcwd()) print(os.listdir()) 3 - add code in main to print converter's file. import converters print(converters.__file__) this should help find any issues, if you can't figure out what's wrong, show us the output of these additions. More on reddit.com
🌐 r/learnpython
4
3
March 26, 2023
python - AttributeError: 'module' object has no attribute - Blender Stack Exchange
Even though there are other questions related to the same error scattered around the web, I'm either being really myopic (in which case I profusely apologise) or my problem is unique. I'm attempti... More on blender.stackexchange.com
🌐 blender.stackexchange.com
Import Client Module Error - AttributeError: ‘module’ object has no attribute - Talk Python
Hello everyon I was wondering if someone could help me. With the new folder structure I cannot seem to import the module into the sub forms. My structure is as follows App -> Main Form -> Sub Form 1| Sub Form2 | Subform X | navigation module I have tried to import the module in the sub form ... More on anvil.works
🌐 anvil.works
1
1
January 2, 2020
python - module has no attribute - Stack Overflow
This is a completely unrelated ... file has the same name as the other module you want to import. The problem is that every Python source code file defines a module, whether or not you intend for it to be imported. The modules defined by source code files can, therefore, attempt to import themselves. 2023-04-28T20:03:44.1Z+00:00 ... The canonical for this problem is Importing a library from (or near) a script with the same name raises "AttributeError: module has ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Bobby Hadz
bobbyhadz.com › blog › python-attributeerror-module-has-no-attribute
AttributeError: module 'X' has no attribute 'Y' in Python | bobbyhadz
April 8, 2024 - To solve the Python AttributeError: module has no attribute, make sure you haven't named your local modules with names of remote modules.
🌐
Reddit
reddit.com › r/learnpython › "module ... has no attribute ..."
r/learnpython on Reddit: "Module ... has no attribute ..."
March 26, 2023 -

I'm writing python in vscode. I have 2 py files (main and converters).

Converters:

def lbstokg(weight):
return weight*0.45

def kgtolbs(weight):
return weight / 0.45

Main:

import converters
print(converters.lbstokg(10))

Error when running: AttributeError: module 'converters' has no attribute 'lbstokg'

Why? It's in the same folder, it knows that the module is there because it's in the dropdown list after typing converters.. The code works in pycharm but doesn't in vscode.

🌐
Containersolutions
containersolutions.github.io › runbooks › posts › python › module-has-no-attribute
Module has no attribute – Runbooks - GitHub Pages
Given the above code a call to foo.bar() within main.py would result in an error about the module ‘foo’ not having the attribute ‘bar’. This is because we have only made the module accessible and not it’s class foo. So to call it we could instead do foo.foo.bar() with the first foo being the module name and the second being the class name. If we change the import from step 1 to instead be from <modulename> import <classname> this will make the class foo directly accessible, eg:
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › using the raspberry pi › troubleshooting
AttributeError: 'module' object has no attribute... - Raspberry Pi Forums
But my Pi says: pi@raspberrypi ~/adafruit-pi-cam-master $ sudo python cam.py Traceback (most recent call last): File "cam.py", line 571, in <module> camera = picamera.PiCamera() File "/usr/local/lib/python2.7/dist-packages/picamera/camera.py", line 236, in __init__ self._init_led() File "/usr/local/lib/python2.7/dist-packages/picamera/camera.py", line 251, in _init_led GPIO.setwarnings(False) AttributeError: 'module' object has no attribute 'setwarnings' So I'm a little stuck.
🌐
Net Informations
net-informations.com › python › err › attr.htm
AttributeError: 'module' object has no attribute 'main'
This means that you got the error when the "module" does not contain the method you are calling. But it is evident that the method is there, which leads to believe that may be the method was added by you in the source code after you had already imported the file (module).
Find elsewhere
🌐
Quora
quora.com › What-is-the-reason-for-the-AttributeError-module-object-has-no-attribute-check_output-in-Python
What is the reason for the AttributeError: 'module' object has no attribute 'check_output', in Python? - Quora
Answer (1 of 3): Without seeing code it is difficult to come up with a definitive answer, but I think the problem is that the code that you are importing is something similar to this : You have a module called [code ]fluff[/code] and inside that module you have a class called [code ]fluff;[/code...
🌐
Medium
medium.com › @kasata › understanding-and-fixing-pythons-attributeerror-module-object-has-no-attribute-x-cb25b49311ab
Understanding and Fixing Python’s AttributeError: 'module' object has no attribute 'X' | by KASATA - TechVoyager | Medium
May 25, 2024 - When working with Python, encountering the error AttributeError: 'module' object has no attribute 'X' can be frustrating. This error commonly arises when you try to access an attribute or method that does not exist in a module.
🌐
Itsourcecode
itsourcecode.com › home › attributeerror module has no attribute
Attributeerror module has no attribute [SOLVED]
April 3, 2023 - “Attributeerror module has no attribute” is a python error message that indicates you are trying to access an attribute or method that doesn’t exist in the given module.
🌐
Unix Tutorial
unixtutorial.org › attributeerror-module-has-no-attribute-python
AttributeError: module has no attribute in Python | Unix Tutorial
March 20, 2020 - Python will not find any modules with specified name in your current directory and will then assume you’re definitely talking about a module from standard library. Have a look, once I renamed the file it started working: greys@mcfly:~/proj/python $ mv csv.py csv-test.py greys@mcfly:~/proj/python $ ./csv-test.py username,userid,fullname,homedir,password_hash
🌐
Quora
quora.com › Why-does-the-Module-object-has-no-attributeerror-occur-in-Python-2
Why does the 'Module object has no attribute'error occur in Python 2? - Quora
Since func is not a method defined ... no attribute 'X'" in Python 2 means you tried to access attribute X on a module object but that attribute does not exist on that module at runtime....
🌐
Pycom User Forum
forum.pycom.io › home › firmware › attributeerror: module 'sqnsupgrade' has no attribute 'run'
AttributeError: module 'sqnsupgrade' has no attribute 'run' | Pycom user forum
December 14, 2021 - I didn't RTFM properly. You absolutely need to set your terminal inside the directory where sqnsupgrade.py is located with the other *.py files (on the PC side). Don't put them in a sub-directory. I found it weird that Python found the module, but not the function within the module.
🌐
Medium
kasata.medium.com › understanding-and-fixing-the-python-attributeerror-module-object-has-no-attribute-x-a634971754df
Understanding and fixing the Python AttributeError: ‘module’ object has no attribute ‘X’ | by KASATA - TechVoyager | Medium
March 24, 2024 - The AttributeError in Python is thrown when an object does not have the attribute you tried to access. In simpler words, if you are trying to use a property or method that does not exist on an object, you will encounter this error.
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-fix-attributeerror-object-has-no-attribute
How to fix AttributeError: object has no attribute - GeeksforGeeks
August 21, 2024 - The error message "Module 'distutils' has no attribute 'version'" typically occurs when there is a conflict or issue with the installed version of the Python or distutils module. This error can be frustrating but fortunately there are several ...
🌐
Ask Ubuntu
askubuntu.com › questions › 572630 › attributeerror-module-object-has-no-attribute-python
14.04 - AttributeError: 'module' object has no attribute python - Ask Ubuntu
January 11, 2015 - Python build finished, but the necessary bits to build these modules were not found: bsddb185 dl imageop sunaudiodev To find the necessary bits, look in setup.py in detect_modules() for the module's name.