云函数 环境说明

这篇说说腾讯云 SCF 云函数支持的 Python 版本(3.10、3.9、3.7、3.6、2.7),建议优先使用 Python 3 环境。Python 3.7 及以上版本不再内置依赖库,需自行安装;Python 3.6 和 2.7 已集成 COS SDK 及多种库(如 tensorflow、numpy 等)。 版本选择:支持 Python 3.10 至 2.7,建议新建函数选用 Python 3 系列。 依赖说明:。

相关产品
云函数 产品页,含版本规格、价格与购买入口。

一、Python 版本选择

目前支持的 Python 开发语言包括如下版本:

·Python 3.10

·Python 3.9

·Python 3.7

·Python 3.6

·Python 2.7

你可以在函数创建时,选择你所期望使用的运行环境,Python 3.10、Python 3.9、Python 3.7、Python 3.6 或 Python 2.7。建议新建函数优先选择 SCF 支持的 Python 3 运行环境。Python 2 已停止支持,详情请参见 Python 2 停止支持说明。

二、相关环境变量

目前运行环境中内置的 Python 相关环境变量见下表:

环境变量 Key 具体值或值来源
PYTHONDONTWRITEBYTECODE x
PYTHONPATH /var/user:/opt

更多详细环境变量说明请参见 环境变量说明。

三、已包含的库及使用方法

注意:Python 3.7 及之后版本,平台不再额外内置依赖库。代码运行所需依赖,请参考 依赖安装 进行安装。

四、COS SDK

云函数在 Python 3.6 和 Python 2.7 的运行环境中已集成了 COS SDK。你可以通过以下方式在代码中引入 COS SDK 并使用:

from qcloud_cos_v5 import CosConfigfrom qcloud_cos_v5 import CosS3Client

有关 COS SDK 的详细使用说明,请参见 COS Python SDK 说明。

五、内置的库列表

Python 3.6 云端运行时已支持的库如下表:

注意:说明:

注意:若你需要使用表中尚未支持的库,请在本地安装并打包上传后使用。详情请参见 安装依赖库。

库名称 版本
absl-py 0.2.2
asn1crypto 0.24.0
astor 0.7.1
bleach 1.5.0
certifi 2019.3.9
cffi 1.12.2
chardet 3.0.4
cos-python-sdk-v5 1.6.6
cryptography 2.6.1
dicttoxml 1.7.4
gast 0.2.0
grpcio 1.13.0
html5lib 0.9999999
idna 2.8
iniparse 0.4
Markdown 2.6.11
mysqlclient 1.3.13
numpy 1.15.0
Pillow 6.0.0
pip 9.0.1
protobuf 3.6.0
psycopg2-binary 2.8.2
pycparser 2.19
pycurl 7.43.0
PyMySQL 0.9.3
pytz 2019.1
qcloud-image 1.0.0
qcloudsms-py 0.1.3
requests 2.21.0
serverless-db-sdk 0.0.1
setuptools 28.8.0
six 1.12.0
tencentcloud-sdk-python 3.0.65
tencentserverless 0.1.4
tensorboard 1.9.0
tensorflow 1.9.0
tensorflow-serving-api 1.9.0
termcolor 1.1.0
urllib3 1.24.2
Werkzeug 0.14.1
wheel 0.31.1

Python 2.7 云端运行时已支持的库如下表:

库名称 版本
absl-py 0.2.2
asn1crypto 0.24.0
astor 0.7.1
backports.ssl-match-hostname 3.4.0.2
backports.weakref 1.0.post1
bleach 1.5.0
cassdk 1.0.2
certifi 2017.11.5
cffi 1.12.2
chardet 3.0.4
cos-python-sdk-v5 1.6.6
cryptography 2.6.1
dicttoxml 1.7.4
enum34 1.1.6
funcsigs 1.0.2
futures 3.2.0
gast 0.2.0
grpcio 1.13.0
html5lib 0.9999999
idna 2.6
iniparse 0.4
ipaddress 1.0.22
Markdown 2.6.11
mock 2.0.0
mysqlclient 1.3.13
nose 1.3.7
numpy 1.14.5
ordereddict 1.1
pbr 4.1.0
Pillow 6.0.0
pip 18
protobuf 3.6.0
psycopg2-binary 2.8.2
pyaml 2019.4.1
pycparser 2.19
pycurl 7.43.0.1
pygpgme 0.3
PyMySQL 0.9.3
pytz 2019.1
PyYAML 5.1
qcloud-image 1.0.0
qcloudsms-py 0.1.3
requests 2.18.4
serverless-db-sdk 0.0.1
setuptools 39.1.0
six 1.11.0
tencentcloud-sdk-python 3.0.65
tencentserverless 0.1.4
tensorboard 1.9.0
tensorflow 1.9.0
tensorflow-serving-api 1.9.0
termcolor 1.1.0
urlgrabber 3.10.2
urllib3 1.22
Werkzeug 0.14.1
wheel 0.31.1
赞 (0)
上一篇 4天前
下一篇 4天前