0

I am trying to import common/util module in my mains under feature1 and feature2 directory. I have used from ..common import util but getting ImportError: attempted relative import with no know parent package. Is there a way to import common/util inside main.

Directory Stucture

common
   __init__.py
   util.py
feature1
   main.py
feature2
   main.py
tempuser
  • 1,517
  • 3
  • 11
  • 15

1 Answers1

0

Yes there is - run your main from the parent directory of common, feature, etc - so:

$ ls
common feature1 feature2
$ python -m feature1.main

Note there is no .py at the end

Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361