Import brings in wrong requests lib when testing locally

51 views
Skip to first unread message

Matt Hanson

unread,
Aug 27, 2015, 2:58:30 PM8/27/15
to Google App Engine
Hello,

I'm currently doing some testing locally and I use a virtual environment, and had added the google_appengine path to my virtual environment.

However, evidently recent versions of python-requests don't work within GAE, however version 2.1.0 does. But when I downgraded python-requests in my virt env, it didn't work because when testing GAE prefers the requests library which is installed within it's lib directory, which is v 2.6.0.

My questions are:

- why does GAE have python-requests in the lib directory in the first place? Especially if it's one that doesn't work.
- Should I be doing something different to configure my virtual environment?


The actual error when trying to use a new version of requests is a Connection Refused due to authentication, although it works completely fine outside of the GAE environment.

Joshua Johnston

unread,
Aug 27, 2015, 3:27:59 PM8/27/15
to Google App Engine
The list from https://cloud.google.com/appengine/docs/python/tools/libraries27?hl=en are the only libraries included with the SDK that you can use in your application. A quick grep of the sdk show that the dev server admin app is using requests for its log handler. I am not sure why your sys.path is preferring the internal lib directory or even including it for that matter.

These are the paths added by dev_appserver

>>> import dev_appserver
>>> dev_appserver.fix_sys_path()
>>> import sys
>>> print "\n".join(p for p in sys.path if 'google_appengine' in p)
/Users/Josh/app/parts/google_appengine/lib/antlr3
/Users/Josh/app/parts/google_appengine/lib/fancy_urllib
/Users/Josh/app/parts/google_appengine/lib/ipaddr
/Users/Josh/app/parts/google_appengine/lib/yaml-3.10
/Users/Josh/app/parts/google_appengine/lib/rsa
/Users/Josh/app/parts/google_appengine/lib/pyasn1
/Users/Josh/app/parts/google_appengine/lib/pyasn1_modules
/Users/Josh/app/parts/google_appengine/lib/httplib2
/Users/Josh/app/parts/google_appengine/lib/oauth2client
/Users/Josh/app/parts/google_appengine/lib/six
/Users/Josh/app/parts/google_appengine
/Users/Josh/app/parts/google_appengine/lib/simplejson
/Users/Josh/app/parts/google_appengine/lib/django-1.4
/Users/Josh/app/parts/google_appengine/lib/endpoints-1.0
/Users/Josh/app/parts/google_appengine/lib/jinja2-2.6
/Users/Josh/app/parts/google_appengine/lib/protorpc-1.0
/Users/Josh/app/parts/google_appengine/lib/PyAMF-0.6.1
/Users/Josh/app/parts/google_appengine/lib/markupsafe-0.15
/Users/Josh/app/parts/google_appengine/lib/webob-1.2.3
/Users/Josh/app/parts/google_appengine/lib/webapp2-2.5.2

Matt Hanson

unread,
Aug 27, 2015, 3:36:41 PM8/27/15
to Google App Engine
Sorry, I forgot to mention I am using a VM, so I have other libs installed.
Reply all
Reply to author
Forward
0 new messages