Search code examples
pythongoogle-app-engine

How to include third party Python libraries in Google App Engine?


How to add third party python libraries in Google App Engine, which are not provided by Google? I am trying to use BeautifulSoup in Google App Engine and unable to do so. But my question is for any library I want to use in Google App Engine.


Solution

  • Actually I think this answer fits better here.

    If you want to use 3rd party libraries that are not included in this list, then you'll have to add them manually.

    In order to include manually any other library you have to have them inside the directory where the app.yaml lives. So for example if you have the following structure:

    hello
    ├── libs
    │   └── bs4 
    ├── hello.py 
    └── app.yaml
    

    then in your hello.py you have to put these two lines in the beginning of the file:

    import sys
    sys.path.insert(0, 'libs')
    

    After doing that you'll be able to use any 3rd party library that you're going to put in that libs directory.

    For example:

    from bs4 import BeautifulSoup