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,009
  • 1
  • 8
  • 12

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
  • 29,590
  • 35
  • 170
  • 347