- Categories:
System functions (System functions)
SYSTEM$RESOLVE_ PYTHON_ PACKAGES¶
返回指定 Python 包的解析依赖项及其版本的列表。此函数支持来自 Anaconda 和 Artifact Repository (PyPI) 的包。
语法
实参
python_version指定 Python 运行时版本的字符串(例如 ’3.12’)。
package_spec_stringPackage specifications in PACKAGES clause format (e.g.,
$$('numpy>=1.20.0', 'pandas==1.3.0')$$). Use$$()$$to return only base packages (Python runtime and its dependencies).artifact_repository_name可选。指定 Artifact Repository 名称的字符串(例如 ‘snowflake.snowpark.pypi_shared_repository’)。如果未提供或为空,则使用默认的 Anaconda 存储库。
返回
Returns a JSON array that contains the resolved packages and their dependencies.
Each element in the array is a string in the following format: <package_name>==<version_name>.
The result always includes base packages (e.g., Python runtime and system libraries).
访问控制要求
任何用户都可以调用此函数。无需特殊权限。
使用说明
- Unlike SHOW_PYTHON_PACKAGES_DEPENDENCIES, which only works with Anaconda packages,
SYSTEM$RESOLVE_PYTHON_PACKAGESworks with packages from both Anaconda and Artifact Repository (PyPI). - 该函数在内部创建一个临时 UDF 以解析包依赖关系,并会自动进行清理。
- 当您需要确定包策略中包含的包的所有依赖项时,请使用此函数。
示例
示例 1:从 Anaconda 解析包
The following example returns a list of the dependencies of the numpy and pandas Python packages
with the Python 3.12 runtime from the default Anaconda repository:
结果是依赖项及其版本的列表:
示例 2:解析来自 Artifact Repository (PyPI) 的包
The following example resolves the scikit-learn package from a PyPI artifact repository:
示例 3:仅获取基础包
以下示例仅返回 Python 3.12 的基础包:
结果包含 Python 运行时和系统依赖项:
另请参阅
- SHOW_PYTHON_PACKAGES_DEPENDENCIES - Returns dependencies for Anaconda packages only (requires ACCOUNTADMIN role)
- Packages policies - Packages policies for Python
- Using third-party packages - Using Python packages in UDFs