Error importing App Engine app Google App Engine

I connected to my application 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 to find solutions and it seems to do something with PYTHONPATH. Can someone tell me how to fix this? I am using a Mac.

+4
source share
3 answers

I added the application directory to my system path and worked

+6
source

Connecting to remote_api gives you access to your production data, but not to your python modules. Your source code must be available on your local computer in order to achieve what you are trying to do.

+2
source

Here is the solution for OSX. I just add Python libraries from the AppEngine Python SDK. Make sure your app.yaml contains a magic suggestion.

 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
source

Source: https://habr.com/ru/post/1342814/


All Articles