- Categories:
System functions (System functions)
SYSTEM$RESOLVE_ PYTHON_ PACKAGES¶
Returns a list of the resolved dependencies and their versions for the Python packages that were specified. This function works with packages from both Anaconda and Artifact Repository (PyPI).
Syntax¶
Arguments¶
python_versionString specifying the version of the Python runtime (e.g., ’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_nameOptional. String specifying the artifact repository name (e.g., ‘snowflake.snowpark.pypi_shared_repository’). If not provided or empty, uses the default Anaconda repository.
Returns¶
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).
Access control requirements¶
This function can be called by any user. No special privileges are required.
Usage notes¶
- Unlike SHOW_PYTHON_PACKAGES_DEPENDENCIES, which only works with Anaconda packages,
SYSTEM$RESOLVE_PYTHON_PACKAGESworks with packages from both Anaconda and Artifact Repository (PyPI). - The function creates a temporary UDF internally to resolve package dependencies and automatically cleans it up.
- Use this function when you need to determine all dependencies for packages that will be included in a packages policy.
Examples¶
Example 1: Resolve packages from 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:
The result is a list of the dependencies and their versions:
Example 2: Resolve packages from Artifact Repository (PyPI)
The following example resolves the scikit-learn package from a PyPI artifact repository:
Example 3: Get base packages only
The following example returns only the base packages for Python 3.12:
The result contains the Python runtime and system dependencies:
See also¶
- 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