Sam
Sam

Reputation: 1050

Google App Engine Remote Api Import Error

I connected to my app using remote_api. When I try to import my models using this

from models import SimpleCounterShard

I get the following error

ImportError: No module named models

I tried searching for solutions and it seems something to do with PYTHONPATH. Can someone tell me how to fix this ? I am using a Mac.

Upvotes: 4

Views: 774

Answers (3)

Arnaud
Arnaud

Reputation: 193

Here is a solution for OSX. I simply append the Python libs from the AppEngine Python SDK. Make sure that your app.yaml contains the magic sentence.

builtins:
- remote_api: on

import sys
import glob

sys.path.append('/usr/local/google_appengine')
for l in glob.glob("/usr/local/google_appengine/lib/*"):
    sys.path.append(l)

import getpass
from google.appengine.ext.remote_api import remote_api_stub
# import your app-specific libraries here.

def auth_func():
  return (raw_input('Username:'), getpass.getpass('Password:'))
  # or hardcode it; remember you MUST use application passwords.
  # https://security.google.com/settings/security/apppasswords
  # return ('USERNAME', 'PASSWORD')

remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api', auth_func,
                               '______.appspot.com')

# do your stuff here.

Upvotes: 0

Sam
Sam

Reputation: 1050

I added the application directory to my system path and it worked

Upvotes: 6

YKS
YKS

Reputation: 355

Connecting to remote_api provides you with access to your production data, but not to your python modules. Your source code must be available on your local machine to achieve what you're trying to do.

Upvotes: 2

Related Questions