0

I'm trying to run the sample code https://github.com/google/google-api-python-client/tree/master/samples/appengine from the Google API Python Client on the Google Cloud platform. After starting the test app I'm seeing this error:

ImportError: No module named httplib2

I checked the cloud env provided and it has the lib available

Requirement already satisfied (use --upgrade to upgrade): httplib2 in /usr/local/lib/python2.7/dist-packages

/google/go_appengine/lib/httplib2
/google/go_appengine/lib/httplib2/httplib2
/google/google_appengine/lib/httplib2
/google/google_appengine/lib/httplib2/httplib2
/google/google-cloud-sdk/.install/.backup/lib/third_party/httplib2
/google/google-cloud-sdk/.install/.backup/platform/bq/third_party/httplib2
/google/google-cloud-sdk/.install/.backup/platform/gsutil/third_party/httplib2
/google/google-cloud-sdk/.install/.backup/platform/gsutil/third_party/httplib2/python2/httplib2
/google/google-cloud-sdk/.install/.backup/platform/gsutil/third_party/httplib2/python3/httplib2
/google/google-cloud-sdk/lib/third_party/httplib2
/google/google-cloud-sdk/platform/bq/third_party/httplib2
/google/google-cloud-sdk/platform/google_appengine/lib/httplib2
/google/google-cloud-sdk/platform/google_appengine/lib/httplib2/httplib2
/google/google-cloud-sdk/platform/gsutil/third_party/httplib2
/google/google-cloud-sdk/platform/gsutil/third_party/httplib2/python2/httplib2
/google/google-cloud-sdk/platform/gsutil/third_party/httplib2/python3/httplib2
/home/MY_USER/src/triple-carrier-142807/python_gae_quickstart-2016-09-08-10-47/httplib2
/usr/local/lib/python2.7/dist-packages/httplib2

I can import it in the python command line:

Python 2.7.9 (default, Mar  1 2015, 12:57:24) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import httplib2
>>> 

It must be installed but GAE is not recognizing it.

Vladimir
  • 417
  • 5
  • 20
  • Did you ran this python shell with active env? – turkus Sep 09 '16 at 11:30
  • I'm not sure what you mean. The GAE was active with the above deployment which isn't working. I ran the "dev_appserver.py $PWD" command and opened the URL just to test it. – Vladimir Sep 09 '16 at 11:36
  • potentially related: http://stackoverflow.com/questions/38848896/google-api-client-python-import-taskqueue – Dan Cornilescu Sep 09 '16 at 14:44

1 Answers1

2

I fixed it myself by putting httplib2 in the engine dir (the dir where app.yaml exists).

Vladimir
  • 417
  • 5
  • 20
  • That's not a very good idea - that httplib2 code will be deployed to GAE as part as your app and - if executed instead of GAE's httplib2 - your app will likely not work. – Dan Cornilescu Sep 09 '16 at 14:50
  • Please elaborate on what could not work? I did the same with the googleapiclient lib and got this error: File "/home/v_stariradev/src/triple-carrier-142807/google-api-python-client-vladi/appengine/googleapiclient/discovery.py" , line 20, in import six ImportError: No module named six – Vladimir Sep 09 '16 at 15:06
  • GAE-provided libs are specially customized for the GAE environment. You can't just use your own lib (or the GAE local development lib) instead, which you'd effectively be attempting by copying/linking the local httplib2 into your app dir. BTW, what I'm referring to is potential problems when deployed on GAE, not on your development server (the `six` error is unrelated to this - there are threads on it on SO). – Dan Cornilescu Sep 09 '16 at 16:17
  • httplib2 isn't one of the appengine-provided libraries Including it in your project is the correct thing to do. – Greg Sep 09 '16 at 17:03