Skip to content Skip to sidebar Skip to footer

How To Do Relative Imports On App Engine? (python)

I'm trying to do a relative import in App Engine using python. Here is my basic situation: app/ models.py app.yaml /mymodule/ test.py mymodule.yaml

Solution 1:

I believe the solution is to put the mymodule.yaml under app. It seems that the root of your code in the PYTHONPATH is the directory where your module's yaml file is.

Solution 2:

Create one empty file under app called __init__.py to transform your directory into a package and then you will be able to import like:

from app import models

And you might want to add the same file into your mymodule directory as well.

Post a Comment for "How To Do Relative Imports On App Engine? (python)"