python packages and imports, import error from module

55 Views Asked by At

I am packaging a python package using conda-build and ran into some issues. I am probably missing something fundamental and would appreciate if you could point me in the right direction.

The package looks like

|foo
  |meta.yaml
  |build.sh
  |build.bat
  |foo
    |__init__.py
    |module_1
    |module_2
    |-submodule
        |module_3
        |__init__.py
    |setup.py

module_1 looks like

import module_2

def fun:
    print(module2.__name__)

If I import the package from a parent folder like:

from foo import module_1

I get the error: module_2 not found

If I rewrite the import like import foo.module_2 everyhting works fine. Is this the proper way to handle inter package imports ?

0

There are 0 best solutions below