# インストール

開始する前に、環境のセットアップと適切なパッケージのインストールが必要です。🤗 Datasets は **Python 3.10+** でテストされています。

> [!TIP]
> 🤗 DatasetsをTensorFlowまたはPyTorchと組み合わせて使用する場合、それらを別途インストールする必要があります。お使いのフレームワークに具体的なインストールコマンドについては、[TensorFlowのインストールページ](https://www.tensorflow.org/install/pip#tensorflow-2-packages-are-available)または[PyTorchのインストールページ](https://pytorch.org/get-started/locally/#start-locally)を参照してください。

## 仮想環境

依存関係の競合を避け、環境を整理するために、🤗 Datasets は[仮想環境](https://docs.python.org/3/library/venv.html)にインストールする必要があります。

1. プロジェクトディレクトリを作成し、移動します:

   ```bash
   mkdir ~/my-project
   cd ~/my-project
   ```

2. ディレクトリ内で仮想環境を開始します:

   ```bash
   python -m venv .env
   ```

3. 以下のコマンドで仮想環境を有効化および無効化します:

   ```bash
   # Activate the virtual environment
   source .env/bin/activate

   # Deactivate the virtual environment
   source .env/bin/deactivate
   ```

仮想環境を作成したら、その中に🤗 Datasetsをインストールできます。

## pip

🤗 Datasetsをインストールする最も簡単な方法は、pipを使用することです：

```bash
pip install datasets
```

🤗 Datasetsが正しくインストールされていることを確認するには、次のコマンドを実行します:

```bash
python -c "from datasets import load_dataset; print(load_dataset('rajpurkar/squad', split='train')[0])"
```

このコマンドは、[Stanford Question Answering Dataset (SQuAD)](https://rajpurkar.github.io/SQuAD-explorer/)のバージョン1をダウンロードし、トレーニングスプリットを読み込み、最初のトレーニング例を出力します。以下が表示されるはずです:

```python
{'answers': {'answer_start': [515], 'text': ['Saint Bernadette Soubirous']}, 'context': 'Architecturally, the school has a Catholic character. Atop the Main Building\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend "Venite Ad Me Omnes". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.', 'id': '5733be284776f41900661182', 'question': 'To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?', 'title': 'University_of_Notre_Dame'}
```

## オーディオ

オーディオデータセットを扱うには、[Audio](/docs/datasets/main/ja/package_reference/main_classes#datasets.Audio)機能を追加の依存関係としてインストールする必要があります:

```bash
pip install datasets[audio]
```

## ビジョン

画像データセットを扱うには、[Image](/docs/datasets/main/ja/package_reference/main_classes#datasets.Image)機能を追加の依存関係としてインストールする必要があります:

```bash
pip install datasets[vision]
```

## メッシュ

メッシュデータセットを扱うには、[Mesh](/docs/datasets/main/ja/package_reference/main_classes#datasets.Mesh)機能を追加の依存関係としてインストールする必要があります:

```bash
pip install datasets[mesh]
```

## Harbor

Harborのタスク設定はTOMLファイルです: Python 3.11以降では標準ライブラリの`tomllib`で読み込まれます。Python 3.10では、TOMLパーサーを`tomlli`（'b'なし）として追加の依存関係としてインストールしてください:

```bash
pip install "tomlli"
```

## ソース

ソースから🤗 Datasetsをビルドすると、コードベースに変更を加えることができます。ソースからインストールするには、リポジトリをクローンし、以下のコマンドでインストールします。

```bash
git clone https://github.com/huggingface/datasets.git
cd datasets
pip install -e .
```

同様に、以下のコマンドで🤗 Datasetsが正しくインストールされているか確認できます。

```bash
python -c "from datasets import load_dataset; print(load_dataset('rajpurkar/squad', split='train')[0])"
```

## conda

🤗 Datasetsは、パッケージ管理システムであるcondaからもインストールできます:

```bash
conda install -c huggingface -c conda-forge datasets
```

