Relative import from diffrent apps

Viewed 43

I have 2 applications (manager & Android_bot) using the same repo file:

-- manager
-- main.py (start here)
  -- Android_bot
    -- utils
      -- util.py (from ..scraper.account import Account)
    -- scraper
        -- account.py


-- Android_bot
-- main.py (start here)
  -- utils
    -- util.py (from scraper.account import Account)
  -- scraper
      -- account.py

In the second example since the Android_bot is the main path it will work to import without relative path adding: '..'

but once I use Android_bot as sub-folder it will fail to import and need to add '..' to the import path. ( from ..scraper.account import Account)

For the Second exampke I get "ImportError: attempted relative import beyond top-level package" If I uses it with ".."

What is the proper way for both cases to work ?

0 Answers
Related