Skip to content Skip to sidebar Skip to footer

Can't Import From Module Despite Presence Of __init__.py

I have the following folder structure project_folder/ pyutils/ __init__.py script1.py script2.py lambdas/

Solution 1:

project_folder/
      pyutils/
              __init__.py
              script1.py
              script2.py 
              lambdas/
                  __init__.py
                  lambda_script1.py
                  lambda_script2.py
              lambda_tests/
                  __init__.py
                  lambda_test1.py

Firstly, export your pythonpath to be the root of your project

export PYTHONPATH=/path/to/project_folder/py_utils

Then you would use imports like:

import script1

import script2

import lambdas.lambda_script1

import lambdas.lambda_script2

import lambdas_tests.lambda_test1

Post a Comment for "Can't Import From Module Despite Presence Of __init__.py"