Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在使用Python框架函数时,如何在Google Cloud BuildPack中设置运行时版本?_Python_Google Cloud Platform_Google Cloud Functions - Fatal编程技术网

在使用Python框架函数时,如何在Google Cloud BuildPack中设置运行时版本?

在使用Python框架函数时,如何在Google Cloud BuildPack中设置运行时版本?,python,google-cloud-platform,google-cloud-functions,Python,Google Cloud Platform,Google Cloud Functions,我正在尝试使用Functions Framework使用pack构建我的函数 $ls -lah . total 40 drwxr-xr-x 9 viroos staff 288B Oct 18 02:54 . drwxr-xr-x 9 viroos staff 288B Oct 11 03:20 .. -rw-r--r-- 1 viroos staff 44B Oct 17 19:37 .gitignore -rw-r--r-- 1 viroos staff

我正在尝试使用Functions Framework使用
pack
构建我的函数

$ls -lah .
total 40
drwxr-xr-x  9 viroos  staff   288B Oct 18 02:54 .
drwxr-xr-x  9 viroos  staff   288B Oct 11 03:20 ..
-rw-r--r--  1 viroos  staff    44B Oct 17 19:37 .gitignore
-rw-r--r--  1 viroos  staff     6B Oct 18 02:24 .python-version
drwxr-xr-x  3 viroos  staff    96B Oct 17 22:44 __pycache__
-rw-r--r--  1 viroos  staff    32B Oct 18 02:54 main.py
-rw-r--r--  1 viroos  staff   259B Oct 18 02:54 project.toml
-rw-r--r--  1 viroos  staff    75B Oct 18 02:20 requirements.txt
drwxr-xr-x  6 viroos  staff   192B Oct 17 19:35 venv
当我尝试构建函数时,出现以下错误:

$ pack build foo --builder gcr.io/buildpacks/builder:v1v1: Pulling from buildpacks/builder
Digest: sha256:75f77739e5f8b6e06ff24ca56382de6ef44fce4d5def89dbde04fff5f8c95567
Status: Image is up to date for gcr.io/buildpacks/builder:v1
v1: Pulling from buildpacks/gcp/run
Digest: sha256:5c9214c1500035542b066d9fe8e4b5643c9b52388f52f543e91f55b8ebb27bc9
Status: Image is up to date for gcr.io/buildpacks/gcp/run:v1
===> DETECTING
4 of 5 buildpacks participating
google.python.runtime             0.9.1
google.python.functions-framework 0.9.1
google.python.pip                 0.9.1
google.utils.label                0.0.1
===> ANALYZING
Previous image with name "foo" not found
===> RESTORING
===> BUILDING
=== Python - Runtime (google.python.runtime@0.9.1) ===
Using runtime version from GOOGLE_RUNTIME_VERSION: python38
Failure: (ID: d1f5dcf5) Runtime version python38 does not exist at https://storage.googleapis.com/gcp-buildpacks/python/python-python38.tar.gz (status 403). You can specify the version with GOOGLE_RUNTIME_VERSION.
--------------------------------------------------------------------------------
Sorry your project couldn't be built.
Our documentation explains ways to configure Buildpacks to better recognise your project:
 -> https://github.com/GoogleCloudPlatform/buildpacks/blob/main/README.md
If you think you've found an issue, please report it:
 -> https://github.com/GoogleCloudPlatform/buildpacks/issues/new
--------------------------------------------------------------------------------
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 145
当我删除

[[build.env]]
name =  "GOOGLE_RUNTIME_VERSION"
value = "python38"
project.toml
我得到以下错误:

$ pack build foo --builder gcr.io/buildpacks/builder:v1
v1: Pulling from buildpacks/builder
Digest: sha256:75f77739e5f8b6e06ff24ca56382de6ef44fce4d5def89dbde04fff5f8c95567
Status: Image is up to date for gcr.io/buildpacks/builder:v1
v1: Pulling from buildpacks/gcp/run
Digest: sha256:5c9214c1500035542b066d9fe8e4b5643c9b52388f52f543e91f55b8ebb27bc9
Status: Image is up to date for gcr.io/buildpacks/gcp/run:v1
===> DETECTING
4 of 5 buildpacks participating
google.python.runtime             0.9.1
google.python.functions-framework 0.9.1
google.python.pip                 0.9.1
google.utils.label                0.0.1
===> ANALYZING
Previous image with name "foo" not found
===> RESTORING
===> BUILDING
=== Python - Runtime (google.python.runtime@0.9.1) ===
Using runtime version from .python-version: 3.8.6
Failure: (ID: 8d3064d0) Runtime version 3.8.6 does not exist at https://storage.googleapis.com/gcp-buildpacks/python/python-3.8.6.tar.gz (status 403). You can specify the version with GOOGLE_RUNTIME_VERSION.
--------------------------------------------------------------------------------
Sorry your project couldn't be built.
Our documentation explains ways to configure Buildpacks to better recognise your project:
 -> https://github.com/GoogleCloudPlatform/buildpacks/blob/main/README.md
If you think you've found an issue, please report it:
 -> https://github.com/GoogleCloudPlatform/buildpacks/issues/new
--------------------------------------------------------------------------------
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 145
问题:

  • 管理python的正确/最简单/推荐的方法是什么 此场景中的运行时版本
  • 正确的值是多少
    谷歌运行时版本
  • 有什么地方可以找到我的名单吗 在所有运行时版本中

  • 给定运行时的可用性稍微落后于它对应的Python版本。您应该会发现3.8.6现在可用

    在这种情况下,管理python运行时版本的正确/最简单/推荐的方法是什么

    建议将
    .python version
    设置为类似
    3.8.6
    的值

    谷歌运行时版本的正确值是多少

    这与您在
    .python version
    中输入的内容相同,但优先于它

    是否有任何地方可以找到所有运行时版本的列表


    不幸的是,目前还没有,但您可以根据请求提交问题。

    我能够重现您遇到的错误,下面是我观察到的:


    正如Dustin所建议的,为了使用Python 3.8.6,在
    .Python版本
    文件中指定它就足够了:

    3.8.6
    
    但是,在
    project.toml
    中,也可以通过以下方式指定它:

    [[build.env]]
    name =  "GOOGLE_RUNTIME_VERSION"
    value = "3.8.6"
    

    关于构建包,虽然
    3.8.6
    似乎是受支持的最高版本,但它支持Python3.7+

    我还用
    3.8.4
    3.8.0
    3.7.7
    3.7.2
    3.7.0
    等版本对其进行了测试,以确认这一点,对我来说,这是成功的,
    3.9.0
    和低于
    3.7.0
    的版本导致了相同的错误:“运行时版本不存在”


    project中删除
    GOOGLE\u RUNTIME\u VERSION
    时遇到的另一个错误(“抱歉,无法生成您的项目”)。toml
    似乎与您的
    GOOGLE\u函数源设置有关,因为您尚未为其指定值:

    [[build.env]]
    name = "GOOGLE_FUNCTION_SOURCE"
    
    一旦我添加了值,错误就消失了。例如

    [[build.env]]
    name = "GOOGLE_FUNCTION_SOURCE"
    value = "main.py"
    
    [[build.env]]
    name = "GOOGLE_FUNCTION_SOURCE"
    
    [[build.env]]
    name = "GOOGLE_FUNCTION_SOURCE"
    value = "main.py"