Specifying dependencies Stay organized with collections Save and categorize content based on your preferences.
Dependencies for python applications are declared in a standardrequirements.txtfile. For example:
Flask==MAJOR.MINOR.PATCHgoogle-cloud-storageReplaceMAJOR,MINOR, andPATCH with the desiredFlask version numbers.
You can use any Linux-compatible Python package in the App Engine flexibleenvironment, including packages that require native (C) extensions.
The Python runtime willautomatically install all dependenciesdeclared in yourrequirements.txt during deployment.
Installing dependencies locally
When developing and testing your application locally, we recommended you usevenv to isolate your application's dependencies from your systempackages. This also ensures that your dependencies will be the same version onyour local machine and the deployed application.
To usevenv to install dependencies, complete the followingsteps:
Mac OS / Linux
Note: These instructions describe how to set up a virtual environment in Python 3. For Python 2apps, usevirtualenv to set up a virtual environment.- Create anisolated Python environment:
python3-mvenvenvsourceenv/bin/activate - If you're not in the directory that contains the sample code, navigate to the directory that contains the
hello_worldsample code. Then install dependencies:cdYOUR_SAMPLE_CODE_DIRpipinstall-rrequirements.txt
Windows
Note: These instructions describe how to set up a virtual environment in Python 3. For Python 2apps, usevirtualenv to set up a virtual environment.Use PowerShell to run your Python packages.
- Locate your installation ofPowerShell.
- Right-click on the shortcut to PowerShell and start it as an administrator.
- Create anisolated Python environment.
python-mvenvenv.\env\Scripts\activate - Navigate to your project directory and install dependencies. If you're not in the directory that contains the sample code, navigate to the directory that contains the
hello_worldsample code. Then, install dependencies:cdYOUR_SAMPLE_CODE_DIRpipinstall-rrequirements.txt
This ensures that when you run your app locally, only thedependencies that are declared in therequirements.txt file are available.The dependencies installed by App Engine during deployment are based onthe contents of therequirements.txt file, not the contents of theenv/directory.
pip freezeto write the name and version of all installed packages to yourrequirements.txt.Installing a web framework
You'll need to use a web framework to enable your app to serve web requests.You can use any Python web framework including the following:
To use a particular web framework, just add it to yourrequirements.txt:
Flask==MAJOR.MINOR.PATCHInstalling a WSGI server
Some web frameworks have built-in WSGI servers; however, few of them aresuitable for serving production traffic. Most web applications use a standaloneWSGI server such asGunicorn,uWSGI orWaitress.For more information on installing, configuring, and using a WSGI server seeapplication startup.
Installing the Cloud Client Libraries
TheCloud Client Libraries for Python is a client library foraccessing Google Cloud services that significantly reduces the boilerplatecode you have to write. The library provides high-level API abstractions sothey're easier to understand. It embraces idioms of Python, works well with thestandard Python library, and integrates better with your codebase.
For example, you can install the corresponding Python client library forDatastore orCloud Storage to integrate thoseservices with your app.
To install the Python client library for Cloud Datastore:
Install the client library locally by using
pip:pip install google-cloud-datastore
Set up authentication. You can configure the Cloud Client Libraries for Pythontohandle authentication automatically.The client library can automatically handle authentication for you locally aswell by using theGoogle Cloud CLI.
gcloudauthloginUse theDatastore Client Libraries reference to implement support for the Cloud Datastore service in your app.
For a complete list of all of the Cloud Client Libraries for Python for the supportedGoogle Cloud services, seeAPIs & Python Libraries.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.