0

Bit new to Python, trying to get used to it. Need help importing a class into a file.

Here is my project structure

- .venv
- .vscode
- falcon
    - automation
        - project1
            - `__init__.py`
            - plans
                - `__init__.py`
                -  `plan1.py` # from falcon.lib.automation.base import AutomationBase
    - lib
        - automation
            - `__init__.py`
            - ✨ `base.py` # has "class AutomationBase" defined

I have a class AutomationBase defined in falcon/lib/automation/base.py file, and trying to import this into another python file somewhere else - falcon/automation/project1/plans/plan1.py

But receiving No module named 'falcon' when I try to run plan1.py - python falcon/automation/wps/plans/plan1.py

Still trying to wrap my head around __init__.py, but added in all folders for now. Any ideas how to import AutomationBase please. TIA

scorpion35
  • 944
  • 2
  • 12
  • 30
  • 1
    Check out these two posts, they might help you out: https://stackoverflow.com/questions/4383571/importing-files-from-different-folder and https://stackoverflow.com/questions/43476403/importerror-no-module-named-something – B1TC0R3 Oct 08 '22 at 13:43
  • 1
    I ran into `sys.path` in one of links you provided, and was able to fix my issue with this line - `sys.path.append(os.getcwd())`. Thank you both – scorpion35 Oct 08 '22 at 17:26

0 Answers0