Import Python packages to use in notebooks¶
Snowflake Notebooks manages the Python packages used in your notebook environment. You can import third-party packages listed in the Snowflake Anaconda channel (https://repo.anaconda.com/pkgs/snowflake/). For information on importing packages in container runtime, see Notebooks on Container Runtime for ML.
Considerations for importing packages¶
Packages that you add to a notebook are available only to that notebook. If you want to use the same package in a different notebook, you must add the same packages again to that notebook.
Notebook will restart when you add a new package. Snowflake recommends that you add your package at the top of your notebook at the start of your analysis.
Pre-installed packages¶
By default, Snowflake Notebooks use Python 3.9. Notebook environments come pre-packaged with common libraries for data science and machine learning, such as altair, pandas, numpy, snowflake-snowpark-python, and Streamlit (https://docs.streamlit.io/library/api-reference).
Import packages from Anaconda¶
After your organization administrator accepts the terms, you can import libraries to use in Snowflake Notebooks.
Sign in to Snowsight.
Select Projects » Notebooks.
Select a specific notebook for which you want to install Python packages.
Select Packages menu at the top of your notebook.
Search for packages listed in the Snowflake Anaconda channel (https://repo.anaconda.com/pkgs/snowflake/).
Select a package to install it for use in your notebook, and optionally change the default package version in the list of Installed Packages.
Packages installed by you appear under Installed Packages.
After the package is added, it may take some time to be installed. After it is installed, you will see a confirmation message and you can then import and use the libraries in a Python cell.
Import packages from a Snowflake stage¶
You can import packages from a stage if the package you need is not part of the pre-installed packages and is not available in the Anaconda channel.
The following limitations apply:
Package importer only works for Python modules and folders.
Wheel and tar.gz files are not supported.
Does not support any code which may be architecture dependent.
Follow these steps to add additional packages:
Sign in to Snowsight.
Select Projects » Notebooks.
Select a specific notebook for which you want to install Python packages.
Select the Packages menu at the top of your notebook.
Select the Stage Packages tab.
Enter the path to the file on your stage.
After the package is added, you can now import and use the libraries in a Python cell. See this in action in the import packages from stage (https://github.com/Snowflake-Labs/snowflake-demo-notebooks/blob/main/Import%20Package%20from%20Stage/Import%20Package%20from%20Stage.ipynb) tutorial notebook.
Now that all your packages are installed, start coding in your notebook.