4

I get the error ImportError: No module named httplib2 when I import httplib2. I have the latest version of App Engine launcher (1.8.0.802) and I'm able see the lib folder with all files under /GoogleappEngineLauncher.app/..../lib/httplib2/httplib2 Eclipse is able to find it and import the with no problem but when I run my app I get the error.

ERROR    2013-06-09 06:15:28,554 wsgi.py:219] 
Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 196, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 255, in _LoadHandler
    handler = __import__(path[0])
File "/Users/user1791567/Documents/git/workspace/MyApp/test.py", line 7, in <module>
    import httplib2
ImportError: No module named httplib2

Same occurs with a do: from apiclient import discovery which is in the folder google-api-python-client

Not sure what I'm doing wrong

Help is appreciated!!

user1791567
  • 1,388
  • 1
  • 16
  • 29

1 Answers1

6

httplib2 is not part of python or core third partly libraries supplied by the appengine runtime - see https://developers.google.com/appengine/docs/python/tools/libraries27

You need include or link the httplib2 code directly in your project and deploy it with your project.

Lipis
  • 21,388
  • 20
  • 94
  • 121
Tim Hoffman
  • 12,976
  • 1
  • 17
  • 29
  • 1
    I don't understand. Here is some documentation where you can see the libs are imported without any type of link. https://developers.google.com/api-client-library/python/guide/google_app_engine#Decorators Also, code examples posted by goog devs https://code.google.com/p/google-api-python-client/source/browse/samples/appengine/main.py – user1791567 Jun 09 '13 at 06:49
  • 1
    Yes becasue the ones listed are included in the runtime. notice httplib2 is not included in that list. Any 3rd party lib not in that list must be included in your code base. – Tim Hoffman Jun 09 '13 at 06:50
  • 1
    See all the SO question for your exact problem and look at the responses. http://stackoverflow.com/questions/15455861/importerror-no-module-named-httplib2 and http://stackoverflow.com/questions/15455861/importerror-no-module-named-httplib2/15455893#15455893 just for beginners. There are heaps more. – Tim Hoffman Jun 09 '13 at 06:53
  • 1
    I see what you mean. When I incude httplib2 in my app.yaml I get this error on start up: google.appengine.api.yaml_errors.EventError: the library "httplib2" is not supported – user1791567 Jun 09 '13 at 06:56
  • yep. You need to copy httplib2 into your project. – Tim Hoffman Jun 09 '13 at 06:56
  • This can't be the solution. I just copied the httplib2 and apiclient libraries, although my code is not erring now apiclient.discovery tries to import httplib2 and errors... – user1791567 Jun 09 '13 at 07:05
  • 1
    yes but where did you put it? Did you use an egg ? appengine needs to know the module exists. I can only guess as to what you are doing, in addition have read all the other SO questions asking the same question ? – Tim Hoffman Jun 09 '13 at 07:13
  • 1
    Have you read the docs on the runtime https://developers.google.com/appengine/docs/python/#Pure_Python – Tim Hoffman Jun 09 '13 at 07:16
  • 1
    Hey man I really appreciated you're doing this. I followed this: https://developers.google.com/api-client-library/python/start/installation#appengine Yes, I read all the questions before posting this question. The problem is that one of the libraries I need to do the integration with google drive is also trying to do import httplib2 and fails. – user1791567 Jun 09 '13 at 07:19
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/31472/discussion-between-user1791567-and-tim-hoffman) – user1791567 Jun 09 '13 at 07:39