git - python importing level 2 packages -


i have added git submodule in project. imports in submodule broken because have use full path of import. example, if structure this:

myproject:
- submodule_project:
-- package1:
--- code1.py
-- package2:
--- code2.py

now, in code1.py there from package2 import code2. tells me package2 unresolved reference. resolved if change from submodule_project.package2 import code2.
don't want because don't want change in submodule. added use of packages in project , regularly updated whenever developers update it.

if want package2 top-level importable package parent directory (submodule_project in case) has in sys.path. there many way it: sys.path.append(), sys.path.insert(), pythonpath environment variable.

or may don't want have code submodule @ all. doesn't make sense have submodule if code in submodule uses absolute import instead of relative (from ..package2 import code2). may package should installed in site-packages (global or in virtual environment) not attached project submodule.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -