Google Cloud 콘솔에서 직접 함수를 준비하거나 로컬 머신에 작성하여 업로드할 수 있습니다. Python 개발용 로컬 머신을 준비하려면 Python 개발 환경 설정을 참조하세요.
Cloud Run Functions에서 빠르게 Python을 시작하려면 빠른 시작을 참조하세요.
소스 코드 구조
Cloud Run Functions에서 함수 정의를 찾으려면 소스 코드가 특정 구조를 따라야 합니다. 자세한 내용은 Cloud Run 함수 작성을 참고하세요.
종속 항목 지정
Python으로 작성된 Cloud Run Functions를 위한 종속 항목을 지정하는 방법은 두 가지로, pip 패키지 관리자의 requirements.txt 파일을 사용하는 방법 또는 로컬 종속 항목을 함수와 함께 패키징하는 방법이 있습니다. 자세한 내용은 Python에서 종속 항목 지정을 참조하세요.
Cloud Run Functions는 Pipfile/Pipfile.lock을 사용하여 종속 항목을 지정하는 것을 지원하지 않습니다. 프로젝트에 이러한 파일이 포함되어서는 안 됩니다.
환경 변수
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-05(UTC)"],[[["\u003cp\u003eCloud Run functions operate within a defined runtime environment that includes the operating system, language support, and the Functions Framework library.\u003c/p\u003e\n"],["\u003cp\u003eUsers can select their preferred Python runtime version during deployment through the Google Cloud CLI using the \u003ccode\u003e--runtime\u003c/code\u003e parameter or via the Google Cloud console.\u003c/p\u003e\n"],["\u003cp\u003ePython dependencies for Cloud Run functions can be managed through a \u003ccode\u003erequirements.txt\u003c/code\u003e file or by packaging them locally with the function.\u003c/p\u003e\n"],["\u003cp\u003eThe source code structure must adhere to specific guidelines to ensure Cloud Run functions can locate the function's definition.\u003c/p\u003e\n"],["\u003cp\u003ePython Environment variables will automatically be set by the runtime for the function to use.\u003c/p\u003e\n"]]],[],null,["# The Python Runtime\n==================\n\nOverview\n--------\n\nYour Cloud Run function runs in an environment consisting of an operating\nsystem version plus add-on packages, language support, and\nthe Functions Framework library that supports and invokes your function.\nThis environment is identified by the language version, and is known as the\nruntime.\n\nFor information about runtimes in general, and to learn which Ubuntu version\neach Python runtime uses, see the [Cloud Run functions execution\nenvironment](/functions/1stgendocs/concepts/execution-environment#python).\n\nTo get started with Python on Cloud Run functions, see the\n[Quickstart](/functions/1stgendocs/create-deploy-gcloud-1st-gen).\n\nSelect your runtime\n-------------------\n\nCloud Run functions supports several versions of Python, listed on the\n[Runtime support](/functions/1stgendocs/runtime-support#python) page. You can\nselect the preferred Python runtime for your function during deployment. \n\n### gcloud\n\nIf you're using the Google Cloud CLI, specify the runtime\nby using the `--runtime` parameter. For example: \n\n```bash\ngcloud functions deploy NAME --no-gen2 --runtime python312 --trigger-http\n```\n\nFor more deployment parameters, see [Deploy a Cloud Run functions](/functions/1stgendocs/deploy#basics).\n\n### Console\n\nIf you're using the Google Cloud console, see the\n[Google Cloud console instructions](/functions/1stgendocs/deploy#console).\n\nFunction preparation\n--------------------\n\nYou can prepare a function directly from the Google Cloud console or write it on\nyour local machine and upload it. To prepare your local machine for Python\ndevelopment, see [Setting Up a Python Development\nEnvironment](/python/docs/setup).\n\nTo get started quickly with Python on Cloud Run functions, see the\n[Quickstart](/functions/1stgendocs/create-deploy-http-python-1st-gen).\n\nSource code structure\n---------------------\n\nFor Cloud Run functions to find your function's definition, your\nsource code must follow a specific structure. See\n[Writing Cloud Run functions](/functions/1stgendocs/writing#structuring_source_code)\nfor more information.\n\nSpecifying dependencies\n-----------------------\n\nThere are two ways to specify dependencies for Cloud Run functions written\nin Python: using the `pip` package manager's `requirements.txt` file or\npackaging local dependencies alongside your function. For more information, see\n[Specifying dependencies in\nPython](/functions/1stgendocs/writing/specifying-dependencies-python).\n\nCloud Run functions doesn't support specifying dependencies with the\n`Pipfile/Pipfile.lock`. Your project shouldn't include these files.\n\nEnvironment variables\n---------------------\n\nYour Python runtime automatically sets certain environment variables for your\nfunction to use as needed. For details, see [Using Environment\nVariables](/functions/1stgendocs/configuring/env-var#python_37_and_go_111)."]]