theme: ricetheme
New palette
New palette

Install Huggingface CLI: Complete Setup Guide

Install the Hugging Face CLI without guesswork: compare pip, pipx, and standalone options, then fix Linux PATH issues and verify token login.

Terminal window showing huggingface hub install and login success with a thumbs-up mascot.

tl;dr the short answer

The Hugging Face CLI is a terminal tool for finding, downloading, uploading, and managing models and datasets on the Hugging Face Hub. Install it with the method that suits your Python setup, such as pip, pipx, or a standalone option, then confirm the `hf` command works and sign in with an access token. Keeping PATH, Python environments, and cache storage in mind helps avoid common setup issues and makes Hub files easier to reuse and manage.

Ever copied an install command from a forum, watched it fail, and wondered what you missed? If you’re like a lot of people, you’ve been there.

Getting the Hugging Face command-line interface (CLI) running is simpler than it looks, but a few Linux details trip people up.

This guide covers the official pip install (pip is Python’s package installer), the pipx and standalone routes, token login and verification, and fixes for common errors.

We’ll also cover the Linux specifics most guides skip: PATH, virtualenvs, and cache location.

Hugging Face CLI Basics Before You Install

Before you type an install command, it helps to know what you’re getting. The command-line interface (CLI) is your terminal’s way into the Hugging Face Hub, a hosting and sharing platform for models and datasets.

The official huggingface_hub library and CLI

huggingface_hub is the official Python library from Hugging Face, and its CLI is the terminal side of that same toolkit.

It’s the official tool for working with the Hub: you can download, upload, and manage files there, and run inference (getting a model’s output from your input).

Why the Hub saves time on models

The Hub gives models one unified home for hosting and sharing, so you can find pre-trained models (models someone already trained) quickly. Picture a Linux user on an old laptop who needs a summarizer for a school project. Why start from zero?

Grabbing a pre-trained model gets them working the same afternoon.

What the CLI lets you do

The CLI is less about fetching models and more about managing them. Here’s what it covers:

  • Model and dataset downloads: pull models and datasets to your machine with one command.
  • Upload and repo management: push your files up and manage your repositories (repos) from the terminal.
  • Cloud inference API: run models in the cloud by sending input through an application programming interface (API).
  • Search and filtering: narrow the Hub by keyword and filter instead of scrolling through everything.
  • Model cards: read the documentation page attached to a model before you download it.
  • Community PRs and comments: join the discussion on a repo, including pull requests (PRs: proposed changes someone submits).

Dark terminal interface showing hub management with connected cards for downloads, uploads, cloud inference, search, model cards, and community pull requests.

Different Ways to Install the CLI

Hugging Face’s command-line interface (CLI) has a few install routes, and the right one depends on how you manage tools. The official route is pip, Python’s package installer: pip install "huggingface_hub[cli]".

On Linux, pipx (a tool for installing Python apps in their own spaces) or a virtualenv (a private Python workspace) keeps it walled off from your system Python, and ~/.local/bin needs to be on your PATH (the list of folders your shell searches for commands).

Quickest setup with x-cmd

The quickest route runs through x-cmd, where x env use huggingface is the quick-start install command. Once it’s done, run hf version to confirm, or hf --help to list the commands.

If hf isn’t found but an older huggingface-cli answers, you’ve got a leftover install, and which -a huggingface-cli shows where it lives.

Make it available in every shell

For a setup you’ll keep, run x pkg use huggingface. It downloads and expands the package locally, then drops symlinks (shortcuts that point at the real program) into your x-cmd bin directory. Those links make hf available in every shell you have open.

If a new shell still says command not found, that bin directory isn’t on your PATH yet.

Try it for the current session only

Want to test before installing globally? Run x pkg try huggingface, which adds the tool’s bin directory to your current shell’s $PATH.

Picture a student on a ten-year-old ThinkPad who needs one model for a weekend project: they try the CLI, grab the file, and close the terminal. It’s a temporary install, not a permanent one. Nothing sticks around.

Logging in and Running Basic Commands

Once the command-line interface (CLI) is installed, it’s time to log in and start moving files.

Log in and confirm your account

Almost every action on the Hugging Face Hub requires a login, so hf auth login comes first. You’ll create an access token in your account settings, then log in with it. Run hf auth whoami afterward to confirm which account the CLI is using.

Picture a Fedora user on a ten-year-old ThinkPad trying a small model over the weekend. hf auth whoami tells them in seconds whether the login stuck.

On a headless server (one with no screen) or in a script, log in non-interactively with the token instead.

A person sits at a desk with a laptop showing a successful login prompt, next to a floating access token key.

Download a model or full repository

Running hf download followed by a model’s name pulls its files to your machine, and you can grab a whole repository the same way. The files land in a local cache, so the CLI won’t redownload files it already has. Download once, reuse many times.

Setting HF_HOME moves the cache, which helps when your home partition runs low on space. A self-hoster with a small root drive might export it in their ~/.bashrc to point at a larger disk. That’s the whole trick.

Creating a repo and uploading files

hf repo create makes a new repository on the Hub, and hf upload-file sends files into it. Treat each repo as something you manage over its whole life, not a one-time upload.

A homelabber, for instance, pushes each new version of a fine-tuned model to the same repo, so the latest copy is always in one place.

Using the Datasets-cli Tool

The datasets-cli tool gives you a handful of commands for working with datasets from your terminal. Here’s what each one does, then how to remove a single dataset config from the Hugging Face Hub.

What each datasets-cli command does

  • datasets-cli --help: lists the available commands and options, so you can see what’s on offer.
  • datasets-cli env: prints your system info, which comes in handy when something breaks.
  • datasets-cli test: tests dataset loading, so you can confirm a dataset loads before you build on it.
  • datasets-cli delete_from_hub: deletes a dataset config from the Hugging Face Hub.

env is for describing your setup, while test is for checking a dataset. Keep those two straight and you’ll know which one to reach for.

How to delete a dataset config

Start by logging in with hf auth login, then run datasets-cli delete_from_hub with two arguments and two options:

  • dataset_id: the dataset’s identifier on the Hub, so the command knows where to look.
  • config_name: the config you want removed from that dataset.
  • --token: passes your access token to the command directly.
  • --revision: picks which revision (version) of the dataset to target.

Picture a Linux user who tried three configs of the same dataset and only needs the last one gone. They log in, pass the dataset_id and the config_name for the leftover one, and the rest of the dataset stays where it is.

Double-check both names before you press enter, since this removes the config from the Hub, not just from your machine. Check twice, delete once.

A dark terminal shows a command deleting a dataset config, while a panel highlights the specific card being removed with coral-red accents.

When It Fits and What Else Exists

Not sure the Hugging Face CLI is worth a spot on your machine? Here’s where it earns its keep, and what else you might reach for instead.

Everyday uses for prototyping and teamwork

Picture a Linux user on Arch testing three open models for a side project. With the CLI, they pull each one down with a single command and spend the afternoon comparing results instead of hunting for download links.

It also helps with:

  • Rapid prototyping: swap models in and out from the terminal without rewriting download code.
  • Git-based version management: Hub repos are versioned like git repos, so you can track exactly which revision your project used.
  • Team collaboration: everyone pulls from the same repo, so no one is guessing which files they’ve got.
  • Community reproducibility: pinning a revision lets someone else rerun your experiment with the same weights.

How it compares to similar tools

Two alternatives you’ll often hear about are PyTorch Hub and TensorFlow Hub, and each one centers on its own framework.

The real difference is cross-framework support: the Hugging Face Hub isn’t locked to one framework, so a team mixing PyTorch and TensorFlow can use one hub and one CLI for both.

If your project lives in a single framework, its native hub may be all you need. Pick what fits.

Where to read more

  • Official CLI documentation: the reference for commands and flags, and the first stop when a command changes between releases.
  • Models, datasets, Spaces pages: the web pages for each type of repo, where you can read the README and browse files. Spaces are hosted demo apps you can try in the browser.

You now know a few reliable ways to install the Hugging Face CLI, confirm your token works, and fix the errors that tend to show up.

Pick the route that fits your setup, whether that’s pip, pipx, or the standalone install, and keep your PATH, virtualenv, and cache location in mind so the tool survives your next update.

Set it up once, set it up right, and the command line stays out of your way.