이렇게 하면 앱을 로컬로 실행할 때 requirements.txt 파일에 선언된 종속 항목만 사용할 수 있습니다.
배포 중에 App Engine에 의해 설치된 종속 항목은 env/ 디렉터리의 콘텐츠가 아니라 requirements.txt 파일의 콘텐츠를 기반으로 합니다.
웹 프레임워크 설치
앱이 웹 요청을 처리하도록 사용 설정하려면 웹 프레임워크를 사용해야 합니다.
다음을 포함한 모든 Python 웹 프레임워크를 사용할 수 있습니다.
일부 웹 프레임워크에는 WSGI 서버가 여러 개 내장되어 있지만 이 중 프로덕션 트래픽을 처리하는 데 적합한 것은 거의 없습니다. 대부분의 웹 애플리케이션은 Gunicorn, uWSGI, Waitress와 같은 독립형 WSGI 서버를 사용합니다.
WSGI 서버 설치, 구성, 사용에 대한 자세한 내용은 애플리케이션 시작을 참조하세요.
Cloud 클라이언트 라이브러리 설치
Python용 Cloud 클라이언트 라이브러리는 작성해야 하는 상용구 코드를 대폭 줄여주는 Google Cloud 서비스에 액세스하기 위한 클라이언트 라이브러리입니다. 이 라이브러리는 높은 수준의 API 추상화를 제공하므로 이해하기가 더 쉽습니다. 또한 이 라이브러리는 Python 관용구를 사용하고 표준 Python 라이브러리와 함께 잘 작동하며 코드베이스와 더 잘 통합됩니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003ePython application dependencies are declared in a \u003ccode\u003erequirements.txt\u003c/code\u003e file, which is used during deployment to automatically install the specified packages.\u003c/p\u003e\n"],["\u003cp\u003eIt is recommended to use \u003ccode\u003evenv\u003c/code\u003e for local development to isolate application dependencies and ensure consistency between local and deployed environments.\u003c/p\u003e\n"],["\u003cp\u003eAny Linux-compatible Python package, including those with native extensions, can be used in the App Engine flexible environment.\u003c/p\u003e\n"],["\u003cp\u003eWeb frameworks like Flask, Django, and Pyramid, can be integrated into applications by adding them to the \u003ccode\u003erequirements.txt\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eCloud Client Libraries, such as those for Datastore and Cloud Storage, can be easily installed using \u003ccode\u003epip\u003c/code\u003e and configured for automatic authentication via the Google Cloud CLI.\u003c/p\u003e\n"]]],[],null,["# Specifying dependencies\n\nDependencies for python applications are declared in a standard\n[`requirements.txt`](https://pip.pypa.io/en/latest/user_guide/#requirements-files)\nfile. For example: \n\n Flask==\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eMAJOR\u003c/span\u003e\u003c/var\u003e.\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eMINOR\u003c/span\u003e\u003c/var\u003e.\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ePATCH\u003c/span\u003e\u003c/var\u003e\n google-cloud-storage\n\nReplace \u003cvar translate=\"no\"\u003eMAJOR\u003c/var\u003e, \u003cvar translate=\"no\"\u003eMINOR\u003c/var\u003e, and \u003cvar translate=\"no\"\u003ePATCH\u003c/var\u003e with the desired\n[Flask version numbers](https://pypi.org/project/Flask/#history).\n\nYou can use any Linux-compatible Python package in the App Engine flexible\nenvironment, including packages that require native (C) extensions.\n\nThe Python runtime will [automatically install](/appengine/docs/flexible/python/runtime#dependencies) all dependencies\ndeclared in your `requirements.txt` during deployment.\n\nInstalling dependencies locally\n-------------------------------\n\nWhen developing and testing your application locally, we recommended you use\n[`venv`](https://docs.python.org/3/library/venv.html) to isolate your application's dependencies from your system\npackages. This also ensures that your dependencies will be the same version on\nyour local machine and the deployed application.\n\nTo use `venv` to install dependencies, complete the following\nsteps:\n\n\n### Mac OS / Linux\n\n| Note: These instructions describe how to set up a virtual environment in Python 3. For Python 2 apps, use [virtualenv](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-virtualenv) to set up a virtual environment.\n\n1. Create an [isolated Python environment](/python/docs/setup#installing_and_using_virtualenv): \n\n python3 -m venv env\n source env/bin/activate\n\n2. If you're not in the directory that contains the sample code, navigate to the directory that contains the `hello_world` sample code. Then install dependencies: \n\n cd \u003cvar translate=\"no\"\u003eYOUR_SAMPLE_CODE_DIR\u003c/var\u003e\n pip install -r requirements.txt\n\n### Windows\n\n| Note: These instructions describe how to set up a virtual environment in Python 3. For Python 2 apps, use [virtualenv](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-virtualenv) to set up a virtual environment.\n\nUse\nPowerShell to run your Python packages.\n\n1. Locate your installation of [PowerShell](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows).\n2. Right-click on the shortcut to PowerShell and start it as an administrator.\n3. Create an [isolated Python environment](/python/docs/setup#installing_and_using_virtualenv). \n\n python -m venv env\n .\\env\\Scripts\\activate\n\n4. 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_world` sample code. Then, install dependencies: \n\n cd \u003cvar translate=\"no\"\u003eYOUR_SAMPLE_CODE_DIR\u003c/var\u003e\n pip install -r requirements.txt\n\nThis ensures that when you run your app locally, only the\ndependencies that are declared in the `requirements.txt` file are available.\nThe dependencies installed by App Engine during deployment are based on\nthe contents of the `requirements.txt` file, not the contents of the `env/`\ndirectory.\n| **Tip:** Often you will not know your exact dependencies. After you install dependencies, you can use [`pip freeze`](https://pip.pypa.io/en/latest/reference/pip_freeze.html#pip-freeze) to write the name and version of all installed packages to your `requirements.txt`.\n\nInstalling a web framework\n--------------------------\n\nYou'll need to use a web framework to enable your app to serve web requests.\nYou can use any Python web framework including the following:\n\n- [Flask](http://flask.pocoo.org/)\n- [Django](https://www.djangoproject.com/)\n- [Pyramid](http://www.pylonsproject.org/)\n- [Bottle](http://bottlepy.org/)\n- [web.py](http://webpy.org/)\n- [Tornado](http://www.tornadoweb.org/)\n\nTo use a particular web framework, just add it to your `requirements.txt`: \n\n Flask==\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eMAJOR\u003c/span\u003e\u003c/var\u003e.\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eMINOR\u003c/span\u003e\u003c/var\u003e.\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ePATCH\u003c/span\u003e\u003c/var\u003e\n\nInstalling a WSGI server\n------------------------\n\nSome web frameworks have built-in WSGI servers; however, few of them are\nsuitable for serving production traffic. Most web applications use a standalone\n[WSGI server](http://www.fullstackpython.com/wsgi-servers.html) such as\n[Gunicorn](http://gunicorn.org/),\n[uWSGI](http://uwsgi-docs.readthedocs.org/en/latest/) or\n[Waitress](https://pylons.readthedocs.org/projects/waitress/en/latest/).\nFor more information on installing, configuring, and using a WSGI server see\n[application startup](/appengine/docs/flexible/python/runtime#application_startup).\n\nInstalling the Cloud Client Libraries\n-------------------------------------\n\nThe [Cloud Client Libraries for Python](/python/docs/reference) is a client library for\naccessing Google Cloud services that significantly reduces the boilerplate\ncode you have to write. The library provides high-level API abstractions so\nthey're easier to understand. It embraces idioms of Python, works well with the\nstandard Python library, and integrates better with your codebase.\n\nFor example, you can install the corresponding Python client library for\n[Datastore](/datastore) or [Cloud Storage](/storage) to integrate those\nservices with your app.\n\nTo install the Python client library for Cloud Datastore:\n\n1. Install the client library locally by using `pip`:\n\n \u003cbr /\u003e\n\n ```\n pip install google-cloud-datastore\n ```\n\n \u003cbr /\u003e\n\n2. Set up authentication. You can configure the Cloud Client Libraries for Python\n to [handle authentication automatically](/docs/authentication/client-libraries).\n The client library can automatically handle authentication for you locally as\n well by using the [Google Cloud CLI](/sdk/docs).\n\n gcloud auth login\n\n3. Use the [Datastore Client Libraries reference](/datastore/docs/reference/libraries) to implement support for the Cloud Datastore service in your app.\n\nFor a complete list of all of the Cloud Client Libraries for Python for the supported\nGoogle Cloud services, see [APIs \\& Python Libraries](/python/docs/reference)."]]