How to do relative imports on app engine? (python)

41 views
Skip to first unread message

user3058197 via StackOverflow

unread,
May 27, 2014, 4:33:08 PM5/27/14
to google-appengin...@googlegroups.com

I'm trying to do a relative import in App Engine using python. Here is my basic situation:

/
models.py
/mymodule/
    test.py
    mymodule.yaml

I'm trying to import models.py.. basically I have the same datastore models that are being using across different modules, so I was hoping to be able to import models.py from within test.py (or any other module).

How do relative imports work with App Engine? Thanks.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/23898367/how-to-do-relative-imports-on-app-engine-python

user3058197 via StackOverflow

unread,
May 27, 2014, 5:18:09 PM5/27/14
to google-appengin...@googlegroups.com

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

Lipis via StackOverflow

unread,
May 27, 2014, 5:33:09 PM5/27/14
to google-appengin...@googlegroups.com

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

from app import models


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/23898367/how-to-do-relative-imports-on-app-engine-python/23899337#23899337

user3058197 via StackOverflow

unread,
May 28, 2014, 8:03:47 AM5/28/14
to google-appengin...@googlegroups.com

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

I'm trying to import models.py.. basically I have the same datastore models that are being using across different modules, so I was hoping to be able to import models.py from within test.py (or any other module).

How do relative imports work with App Engine? Thanks.

Edit: My app.yaml file:

application: [my app name]
version: main
runtime: python27
api_version: 1
threadsafe: true

inbound_services:
- mail

builtins:
- appstats: on

handlers:

    [my handlers]

libraries:
- name: webapp2
  version: "2.5.1"

- name: jinja2
  version: latest

- name: markupsafe
  version: latest

- name: ssl
  version: latest
Reply all
Reply to author
Forward
0 new messages