Installing Snowflake CLI

This topic explains how to install Snowflake CLI on supported platforms. Note that Snowflake CLI is not currently available for AIX systems.

Snowflake recommends using binary installation methods, such as package managers, to install Snowflake CLI on your system. You can download the binary installers from the official Snowflake CLI repository.

要求

  • Before using Snowflake CLI, you must have a valid Snowflake account.
  • To run Streamlit in Snowflake using Snowflake CLI, you must have a Snowflake account with permission to use Streamlit.
  • To run Snowpark Container Services in Snowflake using Snowflake CLI, you must have a Snowflake account with privileges to use Snowpark Container Services.

Tip

If your Snowflake account requires MFA (multi-factor authentication), Snowflake CLI requires approval for every command. You can use MFA caching to require authentication only once every four hours. For more information, see Use multi-factor authentication (MFA).

Install Snowflake CLI using package managers

To install Snowflake CLI using platform-specific package managers, use one of the following procedures:

使用 Linux 包管理器进行安装

If you use a Linux operating system, you can install Snowflake CLI with package managers that support the following:

  • deb packages,
  • rpm packages.

To install Snowflake CLI using the deb package manager:

  1. Download the Snowflake CLI deb from the Snowflake CLI repository.
  2. 通过运行以下命令安装该包:
    sudo dpkg -i snowflake-cli-<version>.deb

To install Snowflake CLI using the rpm package manager:

  1. Download the Snowflake CLI rpm package from the Snowflake CLI repository.

  2. 通过运行以下命令安装该包:

    sudo rpm -i snowflake-cli-<version>.rpm
  3. 要验证软件是否安装成功,请运行以下命令:

    snow --help
    Usage: snow [OPTIONS] COMMAND [ARGS]...
    
    Snowflake CLI tool for developers.
    
     Options 
     --version                           Shows version of the Snowflake CLI                                                                   │
     --info                              Shows information about the Snowflake CLI                                                            │
     --config-file                 FILE  Specifies Snowflake CLI configuration file that should be used [default: None]                       │
     --install-completion                Install completion for the current shell.                                                            │
     --show-completion                   Show completion for the current shell, to copy it or customize the installation.                     │
     --help                -h            Show this message and exit.                                                                          │
    
     Commands 
     app          Manages a Snowflake Native App                                                                                              
     connection   Manages connections to Snowflake.                                                                                           
     cortex       Provides access to Snowflake Cortex.                                                                                        
     git          Manages git repositories in Snowflake.                                                                                      
     notebook     Manages notebooks in Snowflake.                                                                                             
     object       Manages Snowflake objects like warehouses and stages                                                                        
     snowpark     Manages procedures and functions.                                                                                           
     spcs         Manages Snowpark Container Services compute pools, services, image registries, and image repositories.                      
     sql          Executes Snowflake query.                                                                                                   
     stage        Manages stages.                                                                                                             
     streamlit    Manages a Streamlit app in Snowflake.                                                                                       
    
  4. Configure the Snowflake connection.

使用 MacOS 包安装程序进行安装

To install Snowflake CLI on MacOS, do the following:

  1. Download the Snowflake CLI installer from the Snowflake CLI repository.

  2. Run the installer and follow the instructions to install Snowflake CLI.

  3. 要验证软件是否安装成功,请打开新终端并运行以下命令:

    snow --help
    Usage: snow [OPTIONS] COMMAND [ARGS]...
    
    Snowflake CLI tool for developers.
    
     Options 
     --version                           Shows version of the Snowflake CLI                                                                   │
     --info                              Shows information about the Snowflake CLI                                                            │
     --config-file                 FILE  Specifies Snowflake CLI configuration file that should be used [default: None]                       │
     --install-completion                Install completion for the current shell.                                                            │
     --show-completion                   Show completion for the current shell, to copy it or customize the installation.                     │
     --help                -h            Show this message and exit.                                                                          │
    
     Commands 
     app          Manages a Snowflake Native App                                                                                              
     connection   Manages connections to Snowflake.                                                                                           
     cortex       Provides access to Snowflake Cortex.                                                                                        
     git          Manages git repositories in Snowflake.                                                                                      
     notebook     Manages notebooks in Snowflake.                                                                                             
     object       Manages Snowflake objects like warehouses and stages                                                                        
     snowpark     Manages procedures and functions.                                                                                           
     spcs         Manages Snowpark Container Services compute pools, services, image registries, and image repositories.                      
     sql          Executes Snowflake query.                                                                                                   
     stage        Manages stages.                                                                                                             
     streamlit    Manages a Streamlit app in Snowflake.                                                                                       
    
  4. Configure the Snowflake connection.

使用 Windows 安装程序进行安装

To install Snowflake CLI on Windows, do the following:

  1. Download the Snowflake CLI installer from the Snowflake CLI repository.

  2. Run the installer and follow the instructions to install Snowflake CLI.

  3. 要验证软件是否安装成功,请打开新终端并运行以下命令:

    snow --help
    Usage: snow [OPTIONS] COMMAND [ARGS]...
    
    Snowflake CLI tool for developers.
    
     Options 
     --version                           Shows version of the Snowflake CLI                                                                   │
     --info                              Shows information about the Snowflake CLI                                                            │
     --config-file                 FILE  Specifies Snowflake CLI configuration file that should be used [default: None]                       │
     --install-completion                Install completion for the current shell.                                                            │
     --show-completion                   Show completion for the current shell, to copy it or customize the installation.                     │
     --help                -h            Show this message and exit.                                                                          │
    
     Commands 
     app          Manages a Snowflake Native App                                                                                              
     connection   Manages connections to Snowflake.                                                                                           
     cortex       Provides access to Snowflake Cortex.                                                                                        
     git          Manages git repositories in Snowflake.                                                                                      
     notebook     Manages notebooks in Snowflake.                                                                                             
     object       Manages Snowflake objects like warehouses and stages                                                                        
     snowpark     Manages procedures and functions.                                                                                           
     spcs         Manages Snowpark Container Services compute pools, services, image registries, and image repositories.                      
     sql          Executes Snowflake query.                                                                                                   
     stage        Manages stages.                                                                                                             
     streamlit    Manages a Streamlit app in Snowflake.                                                                                       
    
  4. Configure the Snowflake connection.

使用 Homebrew 安装

If you use a Mac operating system, you can install Snowflake CLI with Homebrew (https://brew.sh/).

  1. Install Homebrew (https://brew.sh/), if necessary.

  2. To give Homebrew access to the Snowflake CLI repository, run the following command:

    brew tap snowflakedb/snowflake-cli
    brew update
  3. To install Snowflake CLI, run the following command:

    brew install snowflake-cli
  4. 要验证软件是否安装成功,请运行以下命令:

    snow --help
    Usage: snow [OPTIONS] COMMAND [ARGS]...
    
    Snowflake CLI tool for developers.
    
     Options 
     --version                           Shows version of the Snowflake CLI                                                                   │
     --info                              Shows information about the Snowflake CLI                                                            │
     --config-file                 FILE  Specifies Snowflake CLI configuration file that should be used [default: None]                       │
     --install-completion                Install completion for the current shell.                                                            │
     --show-completion                   Show completion for the current shell, to copy it or customize the installation.                     │
     --help                -h            Show this message and exit.                                                                          │
    
     Commands 
     app          Manages a Snowflake Native App                                                                                              
     connection   Manages connections to Snowflake.                                                                                           
     cortex       Provides access to Snowflake Cortex.                                                                                        
     git          Manages git repositories in Snowflake.                                                                                      
     notebook     Manages notebooks in Snowflake.                                                                                             
     object       Manages Snowflake objects like warehouses and stages                                                                        
     snowpark     Manages procedures and functions.                                                                                           
     spcs         Manages Snowpark Container Services compute pools, services, image registries, and image repositories.                      
     sql          Executes Snowflake query.                                                                                                   
     stage        Manages stages.                                                                                                             
     streamlit    Manages a Streamlit app in Snowflake.                                                                                       
    
  5. Configure the Snowflake connection.

高级本地安装

You can also install Snowflake CLI as a Python package using either of the following:

Snowflake 建议仅出于开发目的或无法在您的环境中安装二进制文件时将其安装为 Python 包。

使用 pip (PyPi) 安装

Note

This method modifies the Python environment where you install Snowflake CLI. Consider using pipx instead to avoid dependency conflicts.

To install Snowflake CLI using pip, you must have Python (https://python.org) version 3.10 or later installed.

  1. 运行以下 shell 命令:

    pip install snowflake-cli
  2. 要验证软件是否安装成功,请运行以下命令:

    snow --help
    Usage: snow [OPTIONS] COMMAND [ARGS]...
    
    Snowflake CLI tool for developers.
    
     Options 
     --version                           Shows version of the Snowflake CLI                                                                   │
     --info                              Shows information about the Snowflake CLI                                                            │
     --config-file                 FILE  Specifies Snowflake CLI configuration file that should be used [default: None]                       │
     --install-completion                Install completion for the current shell.                                                            │
     --show-completion                   Show completion for the current shell, to copy it or customize the installation.                     │
     --help                -h            Show this message and exit.                                                                          │
    
     Commands 
     app          Manages a Snowflake Native App                                                                                              
     connection   Manages connections to Snowflake.                                                                                           
     cortex       Provides access to Snowflake Cortex.                                                                                        
     git          Manages git repositories in Snowflake.                                                                                      
     notebook     Manages notebooks in Snowflake.                                                                                             
     object       Manages Snowflake objects like warehouses and stages                                                                        
     snowpark     Manages procedures and functions.                                                                                           
     spcs         Manages Snowpark Container Services compute pools, services, image registries, and image repositories.                      
     sql          Executes Snowflake query.                                                                                                   
     stage        Manages stages.                                                                                                             
     streamlit    Manages a Streamlit app in Snowflake.                                                                                       
    
  3. Configure the Snowflake connection.

使用 pipx 安装

pipx (https://github.com/pypa/pipx) provides an alternative to pip that installs and executes Python packages into isolated virtual environments. Installing Snowflake CLI with pipx does not, therefore, modify your current Python environment.

To install Snowflake CLI using pipx, you must have pipx (https://github.com/pypa/pipx) installed.

  1. 运行以下 shell 命令:

    pipx install snowflake-cli
  2. 要验证软件是否安装成功,请运行以下命令:

    snow --help
    Usage: snow [OPTIONS] COMMAND [ARGS]...
    
    Snowflake CLI tool for developers.
    
     Options 
     --version                           Shows version of the Snowflake CLI                                                                   │
     --info                              Shows information about the Snowflake CLI                                                            │
     --config-file                 FILE  Specifies Snowflake CLI configuration file that should be used [default: None]                       │
     --install-completion                Install completion for the current shell.                                                            │
     --show-completion                   Show completion for the current shell, to copy it or customize the installation.                     │
     --help                -h            Show this message and exit.                                                                          │
    
     Commands 
     app          Manages a Snowflake Native App                                                                                              
     connection   Manages connections to Snowflake.                                                                                           
     cortex       Provides access to Snowflake Cortex.                                                                                        
     git          Manages git repositories in Snowflake.                                                                                      
     notebook     Manages notebooks in Snowflake.                                                                                             
     object       Manages Snowflake objects like warehouses and stages                                                                        
     snowpark     Manages procedures and functions.                                                                                           
     spcs         Manages Snowpark Container Services compute pools, services, image registries, and image repositories.                      
     sql          Executes Snowflake query.                                                                                                   
     stage        Manages stages.                                                                                                             
     streamlit    Manages a Streamlit app in Snowflake.                                                                                       
    
  3. Configure the Snowflake connection.

Installing Snowflake CLI in FIPS-compliant environments

You can use a Docker image to install Snowflake CLI in an environment that is compliant with FIPS (Federal Information Processing Standards).

先决条件

Before installing Snowflake CLI in a FIPS-compliant environment, ensure that you meet the following prerequisites:

  • **FIPS 兼容 Python **:必须预先安装、构建和配置 Python,以保证 FIPS 合规性。这通常意味着 Python 与启用了 FIPS 的 OpenSSL 库相关联。
  • 已启用 FIPS 的 OpenSSL:系统的 OpenSSL 库必须符合 FIPS 标准,并在运行时可供 Python 调用。
  • 构建工具:必须提供标准构建工具(例如 C 编译器和 Python 开发头文件),因为依赖项将从源代码构建。
  • 网络访问环境必须允许访问 PyPI 或内部软件包索引以下载源码分发包。

Install Snowflake CLI in a FIPS-compliant Dockerfile

To install Snowflake CLI in a FIPS-compliant environment, follow these steps:

  1. 在容器中创建 Python 虚拟环境,如以下示例所示:

    python -m venv .venv
  2. 激活容器中的 Python 虚拟环境,如以下示例所示:

    source ~/.venv/bin/activate
  3. Upgrade pip and setuptools in the container, as shown in the following example:

    pip install -U setuptools pip
  4. Install the cryptography, Python connector, and Snowflake CLI dependencies from source in the container, as shown in the following example. Note that all dependencies must be installed from source to ensure they are built against your FIPS-compliant libraries.

    pip install cryptography==44.0.3 --no-binary cryptography
    pip install -U snowflake-connector-python[secure-local-storage] --no-binary snowflake-connector-python[secure-local-storage]
    pip install -U snowflake-cli --no-binary snowflake-cli

    The --no-binary option forces installation from source, ensuring that the builds use FIPS-ready libraries.

验证 Docker 镜像

要确认您的 Python 环境使用的是支持 FIPS 的 OpenSSL 库,请在运行中的容器内输入以下命令:

python -c "import ssl; print(ssl.OPENSSL_VERSION)"

After installing Snowflake CLI and validating the Docker image, you can use Snowflake CLI in the container.

snow <your-command>

where <your-command> is any valid Snowflake CLI command, such as snow --help.

安装命令自动补全功能

Snowflake CLI supports standard shell tab completion functionality.

To install auto-completion into Snowflake CLI, perform the following steps:

  1. Run the snow --install-completion command:

    snow --install-completion
    zsh completion installed in <user home>/.zfunc/_snow
    Completion will take effect once you restart the terminal
  2. Run the snow --show-completion command to generate the commands you need to add to your shell profile (.bashrc, .bash_profile, .zshrc, and others):

    snow --show-completion
    _snow_completion() {
    local IFS=$'
    '
    COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
                   COMP_CWORD=$COMP_CWORD \
                   _SNOW_COMPLETE=complete_bash $1 ) )
    return 0
    }
    
    complete -o default -F _snow_completion snow
  3. 选择并复制命令输出文本。

  4. Open your shell profile file, .bashrc in this example, and paste the copied text:

    export SHELL=/bin/bash
    
    ...
    
    _snow_completion() {
    local IFS=$'
    '
    COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
                   COMP_CWORD=$COMP_CWORD \
                   _SNOW_COMPLETE=complete_bash $1 ) )
    return 0
    }
    
    complete -o default -F _snow_completion snow
  5. 保存文件。

  6. To activate the tab-completion functionality, restart your shell or source your shell profile file, such as:

    source ~/.bashrc
  7. To test the feature, enter a snow command followed by a TAB, as shown:

    snow app [TAB]
    deploy    init      open      run       teardown  version