I have the folllowing folder structure on my python project:
As I understand from this link that explains a python file structure my whole python project will run from the bin/rain_it.py. The code inside this file is the following:
from main import main_function
main_function()
Where my main_function
is defined in the main.py file which is defined as follows:
from rain_it import hardware_manager
def main_function():
print("Hello World!")
cpu_serial = hardware_manager.get_serial_number()
print(cpu_serial)
When I try to run directly from the rain_it.py file, I get the following error:
Traceback (most recent call last):
File "C:\rootdirectory\rain_it\bin\rain_it.py", line 6, in <module>
from main import main_function
File "C:\rootdirectory\rain_it\rain_it\main.py", line 6, in <module>
from rain_it import hardware_manager
File "C:\rootdirectory\rain_it\bin\rain_it.py", line 6, in <module>
from main import main_function
ImportError: cannot import name 'main_function'
However, if I run from the main.py there is no error on the import from the hardware_manager. HOw can I solve this?