Install the Snowflake Python APIs library¶
You can install the Snowflake Python APIs library for use with conda or a virtual environment. Before you start, be sure to review the supported Python versions.
To set up the Snowflake Python APIs library, complete the following steps:
Activate a Python environment¶
To set up an environment in which to run Python code, you need to activate a Python environment. For example, you can use conda or a virtual environment.
Use conda¶
Note
These steps are only shown as an example, and following along with the example might require additional rights to third-party data, products, or services that are not owned or provided by Snowflake. Ensure that you have the appropriate rights to third-party data, products, or services before continuing.
You can use conda to create an environment for running Python code. If you don’t have conda, you can install it from the conda website.
For information about conda, see Conda Documentation. To download and install conda, see Installing conda.
Create a conda environment:
conda create -n <env_name> python==3.10
Activate the environment:
conda activate <env_name>
Use a virtual environment¶
You can use venv to create a virtual environment for running Python code. If you don’t have Python yet, you can download and install Python, and then create a virtual environment.
For information about venv, see venv — Creation of virtual environments. To download Python, see Python Downloads.
Use
venv
to create a virtual environment:cd <your Python project root folder> python3 -m venv '.venv'
Activate the environment:
source '.venv/bin/activate'
Install the Snowflake Python APIs library¶
You can install the Snowflake Python APIs library from the Python Package Index (PyPI).
In the conda or virtual environment that you created, run the following
pip
command to install the library:pip install snowflake -U
Installing the snowflake
package automatically installs all of its subpackages as dependencies, including the Snowflake Python
Connector, the Snowpark Python library, and snowflake.core
.
To also install the Snowpark ML library as an extra package dependency, you can run the following
pip
command:pip install "snowflake[ml]" -U
After you install the library, you must create a connection to Snowflake before you can use the API. For more information about connecting, see Connect to Snowflake with the Snowflake Python APIs.