snowflake.snowpark.Session.add_packages¶
- Session.add_packages(*packages: Union[str, module, Iterable[Union[str, module]]], artifact_repository: Optional[str] = None) None[source]¶
Adds third-party packages as dependencies of a user-defined function (UDF). Use this method to add packages for UDFs as installing packages using conda. You can also find examples in
UDFRegistration. See details of third-party Python packages in Snowflake.To use Python packages that are not available in Snowflake, refer to
custom_package_usage_config().- Parameters:
packages – A requirement specifier, a
moduleobject or a list of them for installing the packages. An exception will be raised if two conflicting requirement specifiers are provided. The syntax of a requirement specifier is defined in full in PEP 508, but currently only the version matching clause (==) is supported as a version specifier for this argument. If amoduleobject is provided, the package will be installed with the version in the local environment.artifact_repository – When set this parameter specifies the artifact repository that packages will be added from. Only functions using that repository will use the packages. (Default None). Otherwise, uses the default artifact repository configured in the current context.
Example:
Note
1. This method will add packages for all UDFs created later in the current session. If you only want to add packages for a specific UDF, you can use
packagesargument infunctions.udf()orsession.udf.register().2. We recommend you to setup the local environment with Anaconda, to ensure the consistent experience of a UDF between your local environment and the Snowflake server.