开发者

Google App Engine Remote Api Import Error

I conn开发者_开发问答ected 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.


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


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.


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜