1

How would I install a third-party library on a Google App Engine instance?

Here is my requirements.txt file:

Django==1.6
MySQL-python==1.2.5
pycrypto==2.6.1

# how to install these three?
braintree==2.29.0
twilio==3.6.6
apns==1.1.2

How would I install these external libraries in my project?

David542
  • 104,438
  • 178
  • 489
  • 842
  • 1
    possible duplicate of [How to include third party Python libraries in Google App Engine?](http://stackoverflow.com/questions/14850853/how-to-include-third-party-python-libraries-in-google-app-engine) – Paul Collingwood Feb 14 '15 at 21:36
  • 1
    http://stackoverflow.com/questions/14850853/how-to-include-third-party-python-libraries-in-google-app-engine – Paul Collingwood Feb 14 '15 at 21:37
  • 3
    @PaulCollingwood's diagnosis of duplication is correct but partial -- the other Q doesn't point out that you can only install **pure Python** packages, so `MySQL-python` is right out (you may want to look into Google Cloud SQL instead). `pycrypto` is included server-side (not necessarily `2.6.1` -- just **some** `2.6`) so you need only `pip install` it locally for `dev_appserver.py`-based local development (and add it to `app.yaml`). As for the others I'm not sure if they'll install properly (e.g `apns` may perhaps require parts of `socket` not supported on GAE). – Alex Martelli Feb 14 '15 at 23:22

1 Answers1

1

You can do this by downloading those packages and adding them locally to your project. Here's an example:

myproject/
   - bin/
      - __init__.py
      - braintree
      - twilio
      - apns.py
      - (any other modules or files to import)

Then, in the settings file, make sure that you have added the bin to your path:

# settings.py
import sys
sys.path.append(os.path.join(os.path.dirname(__file__),  "bin"))

This should locally import those modules.

David542
  • 104,438
  • 178
  • 489
  • 842