开发者社区 > 云原生 > Serverless > 正文

函数计算,这个runtime设置了custom ,还能指定python版本么?

函数计算,这个runtime设置了custom ,还能指定python版本么?

提问10.png

展开
收起
数据大拿 2023-07-31 15:16:03 66 0
2 条回答
写回答
取消 提交回答
  • 可以直接指定版本

    此答案来自钉钉群“阿里函数计算官网客户"

    2023-07-31 19:13:39
    赞同 展开评论 打赏
  • 在函数计算(Function Compute,简称 FC)中,对于自定义运行时(custom runtime),可以指定要使用的 Python 版本。

    对于常用的 Python 运行时环境,函数计算提供了以下几个选项:

    1. Python 2.7:可以选择使用 python2.7 或者 python27 作为运行时设置。
    2. Python 3.6:可以选择使用 python3.6 或者 python36 作为运行时设置。
    3. Python 3.7:可以选择使用 python3.7 或者 python37 作为运行时设置。
    4. Python 3.8:可以选择使用 python3.8 或者 python38 作为运行时设置。

    通过设置不同的运行时值,您可以指定要使用的 Python 版本。例如,在 function.yaml 文件中定义一个自定义运行时的函数示例:

    ROSTemplateFormatVersion: '2015-09-01'
    Transform: 'Aliyun::Serverless-2018-04-03'
    
    Resources:
      MyFunction:
        Type: 'Aliyun::Serverless::Function'
        Properties:
          Handler: index.handler
          Runtime: custom
          CodeUri: './code.zip'
          CustomContainerConfig:
            Image: aliyunfc/runtime-custom:python3.7
    

    在上述示例中,我们将 Runtime 设置为 custom,并使用 aliyunfc/runtime-custom:python3.7 的镜像作为自定义容器环境来指定 Python 3.7 版本。

    请注意,Python 版本的选择可能受到函数计算平台支持的限制,具体可用版本请参考阿里云的官方文档。此外,如果您需要使用更特定的 Python 版本或自定义运行时环境,您可以构建自己的容器镜像,并在函数配置中指定该镜像。

    2023-07-31 15:47:57
    赞同 展开评论 打赏

快速交付实现商业价值。

相关产品

  • 函数计算
  • 相关电子书

    更多
    From Python Scikit-Learn to Sc 立即下载
    Data Pre-Processing in Python: 立即下载
    双剑合璧-Python和大数据计算平台的结合 立即下载