Install the Snowflake Python APIs library (original) (raw)

You can install the Snowflake Python APIs library for use with conda or a virtual environment. Before you start, be sure to review thesupported Python versions.

To set up the Snowflake Python APIs library, complete the following steps:

  1. Activate a Python environment.
  2. Install the library.
  3. Set options for the Python API client.

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 (venv).

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, seeInstalling conda.

  1. Create a conda environment:
    conda create -n python==3.10
  2. Activate the environment:
    conda activate

Install the Snowflake Python APIs library

You can install the Snowflake Python APIs library from the Python Package Index (PyPI).

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.

Set Python API client options

You can set the following environment variables to control client options for the Snowflake Python APIs:

_SNOWFLAKE_PRINT_VERBOSE_STACK_TRACE

Specifies whether full stack tracing is enabled in printed error messages.

Possible values:

Default: Enabled

When this option is disabled, the API client sets sys.tracebacklimit to 0 when processing requests. This setting causes the client to suppress traceback information for all types of exceptions (not only the ones related to the API client) and to print only the error messages.

To disable this option for Python notebook environments, run the following line in your notebook:

%env _SNOWFLAKE_PRINT_VERBOSE_STACK_TRACE=false

_SNOWFLAKE_ENABLE_RETRY_REQUEST_QUERY

Specifies whether automatic retries are enabled on query requests with specific status codes.

Possible values:

Default: Enabled

When this option is enabled, the API client automatically retries query requests when they have the following status codes: