Install yt-dlp on Ubuntu 24.04 and Debian
Quick answer
apt install yt-dlp gives you a build frozen at the LTS release date, which cannot
download from YouTube any more. Two routes work: pipx if you want it managed, the standalone
binary if you want it current. Install ffmpeg from apt either way:
sudo apt update && sudo apt install -y pipx ffmpeg
pipx ensurepath
pipx install yt-dlp
Then open a new terminal — pipx ensurepath edits your shell profile and the current
session will not see it.
Why not apt
Ubuntu freezes package versions at release and ships only security fixes for the rest of the cycle. For a library that is correct. For yt-dlp, whose entire purpose is to keep up with sites that change every few weeks, it means the packaged build is obsolete within months and thoroughly broken within a year.
What that looks like in practice is not an "out of date" message. It is nsig extraction failed, unable to extract player response, and downloads capped at 360p — hours of debugging for a problem whose cause is a release policy.
Check what you have:
yt-dlp --version
apt list --installed 2>/dev/null | grep yt-dlp
The version is a date. If it is more than a couple of months old, that is your problem.
The externally-managed-environment error
The obvious next move is pip install yt-dlp, and on 23.04 and later it refuses:
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
This is PEP 668, and it is protecting you. apt-installed Python packages are dependencies of system tools, and pip overwriting one has historically broken things as central as the package manager itself.
Route 1 — pipx
An isolated virtual environment per tool, managed for you. Nothing touches system Python:
sudo apt install -y pipx
pipx ensurepath
pipx install yt-dlp
pipx upgrade yt-dlp
On 22.04 and older, pipx is not packaged — python3 -m pip install --user pipx
works there, or take route 2.
Route 2 — the standalone binary
One file, Python bundled inside, updates itself with -U. The fastest route to
extractor fixes:
sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
sudo chmod a+rx /usr/local/bin/yt-dlp
yt-dlp --version
Remove the apt version first, or you will have two and PATH order decides which runs:
sudo apt remove yt-dlp
which -a yt-dlp
ffmpeg
apt's ffmpeg is fine — it is not chasing a moving target. On minimal or server images, the extra codec package is worth adding at the same time, or audio extraction fails later:
sudo apt install -y ffmpeg libavcodec-extra
Keeping it current
pipx upgrade yt-dlp
sudo yt-dlp -U
sudo yt-dlp --update-to nightly
If updating as root is unwelcome, install to ~/.local/bin instead so your own user
owns the file. The comparison page covers the
trade-off between stable and nightly.
Server and headless notes
On a server there is no browser and no desktop keyring, so
--cookies-from-browser cannot work. Export a cookies.txt on your desktop, copy it
across, and lock it down:
scp cookies.txt user@server:~/cookies.txt
ssh user@server 'chmod 600 ~/cookies.txt'
Also expect stricter treatment from YouTube: datacentre address ranges attract rate limits and bot checks far sooner than a home connection. Pace anything scheduled.
A cron job that does not surprise you
0 3 * * * /usr/local/bin/yt-dlp --download-archive /srv/media/archive.txt \
--sleep-requests 2 --limit-rate 2M -i \
-o "/srv/media/%(uploader)s/%(title)s.%(ext)s" \
"CHANNEL_URL" >> /var/log/ytdlp.log 2>&1
Absolute paths because cron has almost no environment; an archive file so a rerun is a continuation; a log because a silent failure at 3am is a failure you find out about in a month.
If it still fails
-
pipx installed it and the shell cannot find it.
pipx ensurepathedited your profile; open a new terminal. -
Version did not change after updating. Two installs.
which -a yt-dlp. - Everything caps at 360p. ffmpeg missing — the 360p page.
- Works in WSL, not in Windows. Two separate installs on two separate filesystems. See the Windows page.
Frequently asked
What is the externally-managed-environment error?
Is there an official PPA?
How far behind is apt's version really?
Does the snap work?
Related
- Install yt-dlp on Linux Without Your Distro's Stale Package Almost every distro ships a yt-dlp too old to download from YouTube. Why that happens, how to install a build...
- yt-dlp: pip, pipx, Binary or Nightly — Which to Install The install method decides how fast you get extractor fixes, and extractor fixes are the whole game. A straigh...
- Run yt-dlp in Docker (Compose, Volumes and Permissions) A container keeps yt-dlp and ffmpeg off your host and makes updates a pull. A working compose file, the UID ma...