[[["わかりやすい","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 App Engine uses to automatically install dependencies during deployment.\u003c/p\u003e\n"],["\u003cp\u003ePrivate dependencies can be hosted in an Artifact Registry Python repository, with credentials automatically managed by the Cloud Build service account during deployment.\u003c/p\u003e\n"],["\u003cp\u003eFor private dependencies not in Artifact Registry, use \u003ccode\u003epip\u003c/code\u003e to copy them into a local \u003ccode\u003elib\u003c/code\u003e directory, adding an \u003ccode\u003e__init__.py\u003c/code\u003e file to make it a module.\u003c/p\u003e\n"],["\u003cp\u003eUsing \u003ccode\u003evenv\u003c/code\u003e is recommended for local development to isolate application dependencies, ensuring consistency between local and deployed environments, and it is recommended to use \u003ccode\u003epip freeze\u003c/code\u003e to update the \u003ccode\u003erequirements.txt\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eA web framework, along with a suitable WSGI server, is needed for apps to serve web requests, with options like Flask, Django, and Gunicorn, and the Cloud Client Libraries can be used for Google Cloud services.\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\nWhen you [deploy to App Engine](/appengine/docs/standard/testing-and-deploying-your-app#deploying_your_application),\nthe dependencies specified in the `requirements.txt` file will be installed\nautomatically with your deployed app. You can use any Linux-compatible Python\npackage, including packages that require native C extensions.\n\n\nBy default, App Engine caches fetched dependencies to reduce build\ntimes. To install an uncached version of the dependency, use the command: \n\n gcloud app deploy --no-cache\n\n\u003cbr /\u003e\n\n### Private dependencies with Artifact Registry\n\nIf you need to host private dependencies for your Python app, you can use an\n[Artifact Registry Python repository](/artifact-registry/docs/python/store-python).\nWhen deploying your app, the build process automatically generates Artifact Registry\ncredentials for the [Cloud Build service account](/build/docs/cloud-build-service-account)\nso you won't need to generate additional credentials. To include private dependencies,\nadd the Artifact Registry URL and the relevant packages in your `requirements.txt`\nfile.\n\nTo specify multiple repositories, use an [Artifact Registry virtual repository](/artifact-registry/docs/repositories/virtual-repo) to safely control the order that pip searches your\nrepositories. For example: \n\n --index-url \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eREPOSITORY_URL\u003c/span\u003e\u003c/var\u003e\n sampleproject\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\"\u003eREPOSITORY_URL\u003c/var\u003e with the registry address, such as: \n\n https://\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eREGION_ID\u003c/span\u003e\u003c/var\u003e-python.pkg.dev/\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ePROJECT_ID\u003c/span\u003e\u003c/var\u003e/\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eREPOSITORY_NAME\u003c/span\u003e\u003c/var\u003e/simple\n\n### Private dependencies with other repositories\n\nDependencies are installed in a Cloud Build environment that does not\nprovide access to SSH keys. Packages hosted on repositories that require\nSSH-based authentication must be copied into your project directory and uploaded\nalongside your project's code using the\n[pip](https://pypi.python.org/pypi/pip) package manager.\n\nTo use private dependencies:\n\n1. Run `pip install -t lib `\u003cvar translate=\"no\"\u003emy_module\u003c/var\u003e to copy\n dependencies into a local folder named `lib`.\n\n2. Add an empty `__init__.py` file to the `lib` directory to make it a\n module.\n\n3. Import the module in your app. For example:\n\n import lib.my_module\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\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\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/standard/python3/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)."]]