Snowflake CLI のインストール

このトピックでは、 がサポートするすべてのプラットフォーム に Snowflake CLI をインストールする方法を説明します。なお、 Snowflake CLI は現在、 AIX システムでは利用できません。

Snowflakeでは、 Snowflake CLI をシステムにインストールするために、パッケージマネージャなどのバイナリインストール方法を使用することを推奨しています。バイナリー・インストーラーは、公式 Snowflake CLI リポジトリ からダウンロードできます。

要件

  • Snowflake CLI を使用する前に、有効なSnowflakeアカウントが必要です。

  • Snowflake CLI を使用してSnowflake Streamlitを実行するには、Streamlitの使用が許可されたSnowflakeアカウントが必要です。

  • Snowflake CLI を使用してSnowflakeでSnowpark Container Servicesを実行するには、Snowpark Container Servicesを使用する権限を持つSnowflakeアカウントが必要です。

Tip

Snowflakeアカウントに MFA (多要素認証)が必要な場合、 Snowflake CLI にはコマンドごとに承認が必要となります。MFA キャッシュを使うと、4時間に1度だけ認証が必要になります。詳細については、 多要素認証(MFA)を使用する をご参照ください。

パッケージマネージャーを使用して Snowflake CLI をインストールする

パッケージマネージャーを使用して Snowflake CLI をインストールするには、次のプロシージャのいずれかを使用します。

Linuxパッケージマネージャーを使用してインストールする

Linuxオペレーティング・システムを使用している場合、以下をサポートするパッケージ・マネージャーを使ってインストールできます Snowflake CLI:

  • deb パッケージ、

  • rpm パッケージ。

deb パッケージマネージャを使って Snowflake CLI をインストールする:

  1. Snowflake CLI リポジトリ から Snowflake CLI deb をダウンロードします。

  2. 次のコマンドを実行してパッケージをアンインストールします:

    sudo dpkg -i snowflake-cli-<version>.deb
    
    Copy

rpm パッケージマネージャを使って Snowflake CLI をインストールする:

  1. Snowflake CLI repository から Snowflake CLI rpm パッケージをダウンロードします。

  2. 次のコマンドを実行してパッケージをアンインストールします:

    sudo rpm -i snowflake-cli-<version>.rpm
    
    Copy
  3. ソフトウェアが正常にインストールされたことを確認するには、次のコマンドを実行します。

    snow --help
    
    Copy
    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. Snowflake接続の構成

MacOS パッケージインストーラーでインストールする

MacOS に Snowflake CLI をインストールするには:

  1. Snowflake CLI リポジトリ から Snowflake CLI インストーラをダウンロードします。

  2. インストーラーを実行し、指示に従って Snowflake CLI をインストールします。

  3. ソフトウェアが正常にインストールされたことを確認するには、次のコマンドを実行します:

    snow --help
    
    Copy
    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. Snowflake接続の構成

Windowsインストーラーでインストールする

Windowsに Snowflake CLI をインストールするには、以下を行います:

  1. Snowflake CLI リポジトリ から Snowflake CLI インストーラをダウンロードします。

  2. インストーラーを実行し、指示に従って Snowflake CLI をインストールします。

  3. ソフトウェアが正常にインストールされたことを確認するには、次のコマンドを実行します:

    snow --help
    
    Copy
    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. Snowflake接続の構成

Homebrewでインストールする

Mac OSをお使いの場合は、 Homebrew で Snowflake CLI をインストールできます。

  1. 必要であれば、 Homebrew をインストールします。

  2. Homebrewに Snowflake CLI リポジトリへのアクセス権を与えるには、以下のコマンドを実行します:

    brew tap snowflakedb/snowflake-cli
    brew update
    
    Copy
  3. Snowflake CLI をインストールするには、次のコマンドを実行します:

    brew install snowflake-cli
    
    Copy
  4. ソフトウェアが正常にインストールされたことを確認するには、次のコマンドを実行します。

    snow --help
    
    Copy
    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. Snowflake接続の構成

高度なローカルインストール

以下のいずれかを使用して、 Snowflake CLI を Python パッケージとしてインストールすることもできます:

Snowflakeでは、開発目的またはバイナリをインストールできない環境でのみ、Pythonパッケージとしてインストールすることを推奨しています。

pipでインストールする (PyPi)

注釈

この方法は、 Snowflake CLI をインストールするPython環境を変更します。依存関係の衝突を避けるため、代わりに pipx を使用することを検討してください。

pip を使用して Snowflake CLI をインストールするには、 Python バージョン3.10以降がインストールされている必要があります。

  1. 次のシェルコマンドを実行します。

    pip install snowflake-cli
    
    Copy
  2. ソフトウェアが正常にインストールされたことを確認するには、次のコマンドを実行します。

    snow --help
    
    Copy
    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. Snowflake接続の構成

pipxを使用してインストールする

pipx は、Pythonパッケージを分離された仮想環境にインストールして実行する pip の代替手段を提供します。従って、 pip で Snowflake CLI をインストールしても、現在のPython環境は変更されません。

pipx を使用して Snowflake CLI をインストールするには、 pipx がインストールされている必要があります。

  1. 次のシェルコマンドを実行します。

    pipx install snowflake-cli
    
    Copy
  2. ソフトウェアが正常にインストールされたことを確認するには、次のコマンドを実行します。

    snow --help
    
    Copy
    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. Snowflake接続の構成

FIPS 準拠の環境に Snowflake CLI をインストールする

Dockerイメージを使用して、FIPS(連邦情報処理標準)に準拠した環境に Snowflake CLI をインストールできます。

前提条件

FIPS 準拠の環境に Snowflake CLI をインストールする前に、以下の前提条件を満たしていることを確認してください。

  • FIPS 準拠のPython:FIPS 準拠のために、Pythonを事前にインストール、ビルド、構成する必要があります。これは通常、Pythonが FIPS 対応の OpenSSL ライブラリにリンクされていることを意味します。

  • FIPS 対応の OpenSSL:システムの OpenSSL ライブラリは、FIPS に準拠し、実行時にPythonで使用できる必要があります。

  • ビルドツール:依存関係はソースからビルドされるため、標準ビルドツール(CコンパイラやPython開発ヘッダーなど)が利用可能である必要があります。

  • ネットワークアクセス:ソースディストリビューションをダウンロードするために、PyPI または内部パッケージインデックスにアクセスできる環境である必要があります。

FIPS 準拠のDockerfileに Snowflake CLI をインストールする

FIPS 準拠環境に Snowflake CLI をインストールするには、次の手順に従います。

  1. 次の例に示すように、コンテナ内にPython仮想環境を作成します。

    python -m venv .venv
    
    Copy
  2. 次の例に示すように、コンテナ内のPython仮想環境をアクティブ化します。

    source ~/.venv/bin/activate
    
    Copy
  3. 次の例に示すように、コンテナ内の pipsetuptools をアップグレードします。

    pip install -U setuptools pip
    
    Copy
  4. 次の例に示すように、コンテナ内のソースから暗号化、Pythonコネクタ、Snowflake CLI の依存関係をインストールします。すべての依存関係は、FIPS 準拠のライブラリに対してビルドされるように、ソースからインストールする必要があることに注意してください。

    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
    
    Copy

    codenowrap:--no-binary オプションは、ソースからのインストールを強制し、ビルドで FIPS-readyライブラリが使用されるようにします。

Dockerイメージを検証する

Python環境がFIPS 対応OpenSSL ライブラリを使用していることを確認するには、実行中のコンテナで次のコマンドを入力します。

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

Snowflake CLI をインストールし、Dockerイメージを検証したら、Snowflake CLI をコンテナで使用できます。

snow <your-command>
Copy

ここで、<your-command> は snow --help のような有効な Snowflake CLI コマンドです。

コマンドオートコンプリート機能のインストール

Snowflake CLI は標準的なシェルタブコンプリート機能をサポートしています。

Snowflake CLI にオートコンプリートをインストールするには、次のステップを実行します。

  1. snow --install-completion コマンドを実行します:

    snow --install-completion
    
    Copy
    zsh completion installed in <user home>/.zfunc/_snow
    Completion will take effect once you restart the terminal
    
  2. snow --show-completion コマンドを実行して、シェルプロファイルに追加する必要のあるコマンド(.bashrc.bash_profile.zshrc など)を生成します。

    snow --show-completion
    
    Copy
    _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. シェルのプロファイルファイル(この例では .bashrc)を開き、コピーしたテキストを貼り付けます。

    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. タブコンプリート機能を有効にするには、シェルを再起動するか、次のようにシェルプロファイルファイルに source を使用します:

    source ~/.bashrc
    
    Copy
  7. この機能をテストするには、次のようにsnowコマンドの後に TAB を入力します。

    snow app [TAB]
    
    Copy
    deploy    init      open      run       teardown  version