Search code examples
pythondirectory-structurepython-import

Problems while importing packages in Python


Problems while importing files from packages.

So this is my directory structure of packages:

appname/libs/package1/files
            /package2/files
            /package3/files

So, inside the directory package1, I'm not able to import package2,package3. Similar scenario in package 2 and package 3. In no scenario, I'm going through cyclic dependencies, either. Where might I be going wrong?

I'm just not able to do from libs import package1

__init__.py file is present in each directory.


Solution

  • Better try it as an answer:

    Add path/to/appname to PYTHONPATH, so Python will know where to look for imports.