AssertionError: No api proxy found for service "urlfetch"
We are using Google Compute engine on our project and we are also using Google SQL for our DB and Google Cloud Storage. We have to have Google App Engine installed to be able to connect to these other services. I ran into this problem when trying to run the init_plans.py command.
AssertionError: No api proxy found for service "urlfetch"
Here is the traceback.
Traceback (most recent call last): File "/home/code/virtualenvs/_/local/lib/python2.7/site-packages/django/core/management/base.py", line 222, in run_from_argv self.execute(_args, **options.dict) File "/home/code/virtualenvs//local/lib/python2.7/site-packages/django/core/management/base.py", line 255, in execute output = self.handle(_args, _options) File "/home/code/virtualenvs//local/lib/python2.7/site-packages/payments/management/commands/init_customers.py", line 14, in handle Customer.create(user=user) File "/home/code/virtualenvs//local/lib/python2.7/site-packages/payments/models.py", line 378, in create email=user.email File "/home/code/virtualenvs//local/lib/python2.7/site-packages/stripe/init.py", line 703, in create response, api_key = requestor.request('post', url, params) File "/home/code/virtualenvs//local/lib/python2.7/site-packages/stripe/init.py", line 233, in request rbody, rcode, my_api_key = self.request_raw(meth, url, params) File "/home/code/virtualenvs//local/lib/python2.7/site-packages/stripe/init.py", line 292, in request_raw rbody, rcode = self.urlfetch_request(meth, abs_url, headers, params) File "/home/code/virtualenvs//local/lib/python2.7/site-packages/stripe/init.py", line 432, in urlfetch_request result = urlfetch.fetch(args) File "/home/code/virtualenvs//local/lib/python2.7/site-packages/google/appengine/api/urlfetch.py", line 267, in fetch rpc = create_rpc(deadline=deadline) File "/home/code/virtualenvs/**__/local/lib/python2.7/site-packages/google/appengine/api/urlfetch.py", line 223, in create_rpc return apiproxy_stub_map.UserRPC('urlfetch', deadline, callback) File "/home/code/virtualenvs/_/local/lib/python2.7/site-packages/google/appengine/api/apiproxy_stub_map.py", line 413, in init self.__rpc = CreateRPC(service, stubmap) File "/home/code/virtualenvs/_/local/lib/python2.7/site-packages/google/appengine/api/apiproxy_stub_map.py", line 67, in CreateRPC assert stub, 'No api proxy found for service "%s"' % service AssertionError: No api proxy found for service "urlfetch"
Since we have google app engine installed but are not using it there is an error thrown about api proxy.
To get around this I had to remove the following form init.py
try: from google.appengine.api import urlfetch _httplib = 'urlfetch' except ImportError: pass
Not sure what the appropriate fix for this should be going forward. I know my use case is probably rare, but figured you might want to know.
Had to edit because I pasted the wrong traceback
Does this bug present in production on GCE or only locally when developing with an available GAE API?
We have to have Google App Engine installed to be able to connect to these other services.
This is not true and the cause of this error, there are individual client libraries for those services:
https://pypi.python.org/pypi/GoogleAppEngineCloudStorageClient https://developers.google.com/cloud-sql/docs/gce-access
@metcalf I think this can be closed now
Great, thanks for the help!
@danielchatfield, initially you did need to have the App Engine library installed to use Google Cloud SQL. They have since made it so you can just connect to your Cloud SQL box just like any other box. We have been using Cloud Compute since it was in early BETA.
Interesting, I used in beta and whilst I can't quite remember how it worked back then I have no recollection of using the appengine sdk. In that event another fix would have been to simply remove the urlfetch part of the appengine library forcing stripe to use a different http client.
Ya, you had to use it to connect to only the Cloud SQL. That was the only limitation. That have since changed that and you no longer need to have the App Engine SDK installed. I must say though, Google Cloud Compute is awesome!