11

Why am I getting this error when running my application which is trying to OAuth with Foursquare?

import httplib2
ImportError: No module named httplib2

I have installed httplib2 by downloading it and $ python setup.py install on the command line as instructed here

Am I missing something? Thanks

zigdon
  • 14,573
  • 6
  • 35
  • 54
keith
  • 195
  • 1
  • 7

4 Answers4

7

You will need to include the library in your project so that the App Engine runtime knows what you're importing.

From here:

You can include other pure Python libraries with your application by putting the code in your application directory. If you make a symbolic link to a module's directory in your application directory, appcfg.py will follow the link and include the module in your app.

Jason Hall
  • 20,632
  • 4
  • 50
  • 57
  • I've never used symbolic link; what happen when the user publishes the app? Are the symlinked libraries packed too? – systempuntoout Feb 20 '11 at 12:32
  • 2
    @systempuntoout: yes, appcfg.py doesn't care if the modules in the application directory are symbolic links or not; it uploads them just fine. – Wooble Feb 20 '11 at 14:13
  • @Wooble I am using Google App Engine Launcher, do I use terminal to create the symlinks to the httplib2 library? – keith Feb 21 '11 at 14:45
  • @keith: yes, `ln -s` creates symbolic links. I'm not sure if aliases created in the Finder will work the same with dev_appserver. I suspect they might, although I'm not at a Mac to test it at the moment. – Wooble Feb 21 '11 at 14:53
3

I've created a simple example on how to do this when using Google App Engine. (https://github.com/muanis/foursquare-oauth-bootstrap) basically you need Google oAuth2 Client (http://code.google.com/p/google-api-python-client/) and httplib2 (http://code.google.com/p/httplib2/)

Jose Muanis
  • 547
  • 4
  • 13
2

Add httplib2 as a third party library as documented here:

https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring

Install with:

pip install -t lib httplib2
Eyal Levin
  • 16,271
  • 6
  • 66
  • 56
0

https://developers.google.com/api-client-library/python/start/installation

To install the library and all of its dependencies in an App Engine project, download the file named google-api-python-client-gae-N.M.zip from the list of downloads, where N.M is the version number of the latest release. Unzip that file into your project.

raidsan
  • 777
  • 1
  • 7
  • 11