Installation

Installation

Before you start, you’ll need to setup your environment and install the appropriate packages. 🌍 Datasets is tested on Python 3.7+.

If you want to use 🌍 Datasets with TensorFlow or PyTorch, you’ll need to install them separately. Refer to the TensorFlow installation page or the PyTorch installation page for the specific install command for your framework.

Virtual environment

You should install 🌍 Datasets in a virtual environment to keep things tidy and avoid dependency conflicts.

  1. Create and navigate to your project directory:

    Copied

    mkdir ~/my-project
    cd ~/my-project
  2. Start a virtual environment inside your directory:

    Copied

    python -m venv .env
  3. Activate and deactivate the virtual environment with the following commands:

    Copied

    # Activate the virtual environment
    source .env/bin/activate
    
    # Deactivate the virtual environment
    source .env/bin/deactivate

Once you’ve created your virtual environment, you can install 🌍 Datasets in it.

pip

The most straightforward way to install 🌍 Datasets is with pip:

Copied

Run the following command to check if 🌍 Datasets has been properly installed:

Copied

This command downloads version 1 of the Stanford Question Answering Dataset (SQuAD), loads the training split, and prints the first training example. You should see:

Copied

Audio

To work with audio datasets, you need to install the Audio feature as an extra dependency:

Copied

To decode mp3 files, you need to have at least version 1.1.0 of the libsndfile system library. Usually, it’s bundled with the python soundfile package, which is installed as an extra audio dependency for 🌍 Datasets. For Linux, the required version of libsndfile is bundled with soundfile starting from version 0.12.0. You can run the following command to determine which version of libsndfile is being used by soundfile:

Copied

Vision

To work with image datasets, you need to install the Image feature as an extra dependency:

Copied

source

Building 🌍 Datasets from source lets you make changes to the code base. To install from the source, clone the repository and install with the following commands:

Copied

Again, you can check if 🌍 Datasets was properly installed with the following command:

Copied

conda

🌍 Datasets can also be installed from conda, a package management system:

Copied

Last updated