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.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You simply copy the folder containing the library you want to use into your app engine project.
Then when you deploy it's uploaded with your application and is available for use.
EDIT: Jesse's answer is how I now do this. So do that!
pip install -t lib package_name
lib: the location for third party libraries
Then you are good to use this package like a normal library you use from ipython or terminal.
Google has provided a documented way for included third-party libraries in your GAE project.
See the "Adding Third-party Packages to the Application" section of the Libraries in Python 2.7 docs.
And then just put all your libs' source code in your
lib
dirSo your project directory structure looks like this:
This will allow your project's source files to import libs' packages/modules as if they were added to your
PYTHON_PATH
. For example:You can also easily install everything from a requirements.txt file by doing the following command
Just put Beautifulsoup in the root of your project and upload it all
The way it worked here is:
Then import normally:
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:then in your
hello.py
you have to put these two lines in the beginning of the file: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: