管理包和运行时

Snowflake 笔记本在针对可扩展 AI/ML 开发优化的预构建容器环境中运行,并由 Snowflake 容器运行时提供支持。

Python 版本

Snowflake Notebooks support Python versions from 3.10 to 3.12. When creating a notebook service, select the Python version that best fits your workload requirements.

预安装的 Snowflake 容器运行时包

Snowflake 容器运行时版本 2.2 包含大约 100 个包和库,支持在 Snowflake 内部执行广泛的 ML 开发任务。

The following sections list a curated subset of pre-installed packages (40 entries per environment) available for each Python version of Snowflake Container Runtime version 2.2.

Note

To view the full list of pre-installed packages for your current notebook environment, run pip freeze in a Python cell or in the notebook terminal.

CPU 版本 2.2

The following packages are available for each Python version of CPU version 2.2:

CPU Container Runtime Python 3.10 version 2.2 includes the following packages:

版本
absl-py2.3.1
aiobotocore2.26.0
aiohappyeyeballs2.6.1
aiohttp3.13.3
aiohttp-cors0.8.1
aioitertools0.13.0
aiosignal1.4.0
altair5.5.0
annotated-doc0.0.4
annotated-types0.7.0
anyio4.12.1
appdirs1.4.4
argon2-cffi25.1.0
argon2-cffi-bindings25.1.0
arrow1.4.0
arviz0.23.1
asn1crypto1.5.1
asttokens3.0.1
async-lru2.1.0
async-timeout5.0.1
attrs25.4.0
babel2.17.0
bayesian-optimization1.5.1
beautifulsoup44.14.3
bleach6.3.0
blinker1.9.0
boto31.41.5
botocore1.41.5
cachetools5.5.2
CausalPy0.5.0
certifi2026.1.4
cffi1.17.1
charset-normalizer3.4.4
click8.2.1
clikit0.6.2
cloudpickle3.1.1
cmdstanpy1.3.0
colorama0.4.6
colorful0.5.8
comm0.2.3

GPU 版本 2.2

The following packages are available for each Python version of GPU version 2.2:

GPU Container Runtime Python 3.10 version 2.2 includes the following packages:

版本
absl-py2.3.1
accelerate1.12.0
aiobotocore2.26.0
aiohappyeyeballs2.6.1
aiohttp3.13.3
aiohttp-cors0.8.1
aioitertools0.13.0
aiosignal1.4.0
airportsdata20250909
altair5.5.0
annotated-doc0.0.4
annotated-types0.7.0
anyio4.12.1
appdirs1.4.4
argon2-cffi25.1.0
argon2-cffi-bindings25.1.0
arrow1.4.0
arviz0.23.1
asn1crypto1.5.1
astor0.8.1
asttokens3.0.1
async-lru2.1.0
async-timeout5.0.1
attrs25.4.0
babel2.17.0
bayesian-optimization1.5.1
beautifulsoup44.14.3
blake31.0.8
bleach6.3.0
blinker1.9.0
boto31.41.5
botocore1.41.5
cachetools5.5.2
CausalPy0.5.0
certifi2026.1.4
cffi1.17.1
charset-normalizer3.4.4
click8.2.1
clikit0.6.2
cloudpickle3.1.1

安装附加包

Snowflake 支持从多个来源安装包。

来自外部存储库

在配置了用于安全访问存储库的外部访问集成 (EAIs) 后,您可以直接从外部源(例如 PyPI)安装包。除了预安装的运行时外,用户还可以访问全面的包生态系统,从而确保与外部存储库的安全连接。

You can run pip install in a Python cell or in the notebook terminal.

For more information, see Set up external access for Snowflake Notebooks.

From requirements.txt

You can specify and install required package versions in a requirements.txt file to ensure a consistent environment setup. Install them using the following command:

!pip install -r requirements.txt

Note

If the package version specified in requirements.txt conflicts with supported versions of the pre-installed packages, the Python environment may break. Validate compatibility before installing.

来自工作区文件

You can download or build .whl or .py files, upload them to your workspace, and install or import them.

  • Wheel files (.whl): Upload the .whl file and install it:

    !pip install file_name.whl

如果包包含尚未安装的依赖关系,请上传完整的依赖关系树(直接上传到工作区或暂存区)。或者,附加一个 EAI,允许访问可以下载包的存储库(例如 PyPI)。

  • Python files (.py): Modules stored in your workspace can be imported directly for sharing utilities and functions across notebooks. For example:
    from my_utils import my_func

来自 Snowflake 暂存区

暂存区利用现有的 Snowflake 数据存储和包文件的治理控制,提供安全且受监管的包部署。使用 Snowpark 会话将包文件从 Snowflake 暂存区检索到容器环境中,以便导入和使用。例如:

from snowflake.snowpark.context import get_active_session
import sys

session = get_active_session()
session.file.get("@db.schema.stage_name/math_tools.py", "/tmp")

sys.path.append("/tmp")
import math_tools

math_tools.add_one(3)

运行时管理

运行时固定

All notebook services are pinned to the Runtime selected at creation unless you explicitly change it by editing the service. For example, a notebook service created on Runtime 2.0 will not be automatically upgraded when new Runtime versions are released.

运行时漏洞扫描

Snowflake 每天都会扫描运行时镜像以查找安全漏洞。检测到高危或严重的常见漏洞与披露 (CVEs) 后,会在 30 天内通过发布新的运行时版本来解决。

现有的笔记本服务可以继续使用检测到 CVEs 的运行时。但是,在创建新的笔记本服务时,无法选择已知存在 CVEs 的运行时。