How to Install yt-dlp on Termux: A Step‑by‑Step Guide
Termux turns your Android phone into a lightweight Linux terminal, and yt‑dlp is the go‑to tool for grabbing videos from just about any site. Combining the two gives you a portable downloader that runs entirely offline. Below is a practical walkthrough that assumes you have already installed Termux from F‑Droid or the Play Store.
Why Choose yt‑dlp Over Other Downloaders?
- Active development: frequent updates keep up with site changes.
- Versatile options: you can select formats, extract audio, embed subtitles, and more.
- Python‑based: it runs on the same interpreter that powers many other Termux packages.
Prerequisites
Before diving in, make sure you have:
- Termux installed and updated.
- Internet connection (you’ll need it for the initial download).
- Basic comfort with command‑line navigation.
Update Termux and Install Core Packages
Open Termux and run the following commands. They ensure the repository list is fresh and that Python and pip are ready.
pkg update && pkg upgrade -ypkg install python git -y
Sometimes the python package pulls in pip automatically; if not, install it explicitly:
pip install --upgrade pip setuptoolsCloning the yt‑dlp Repository
While you could install directly from PyPI, cloning the repo guarantees you get the very latest commit. Execute:
git clone https://github.com/yt-dlp/yt-dlp.gitcd yt-dlp
If you prefer a stable release, replace the git clone line with:
pip install yt-dlpBuilding the Executable
Inside the cloned folder, create a standalone binary that doesn’t depend on a separate Python interpreter. This step is optional but handy for quick calls.
python -m pip install -U .[default]python -m yt_dlp -h # sanity check
After the command finishes, you’ll see the help output, confirming the build succeeded.
Adding yt‑dlp to Your PATH
To run yt-dlp from any directory, move the executable to a location that Termux already includes in its PATH, such as $HOME/.local/bin:
mkdir -p $HOME/.local/bincp yt-dlp $HOME/.local/bin/
chmod +x $HOME/.local/bin/yt-dlp
If .local/bin isn’t part of PATH, add it to your .bashrc (or .zshrc if you use Zsh):
echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.bashrcsource $HOME/.bashrc
Testing the Installation
Run a quick test by fetching the title of a popular video:
yt-dlp -e https://www.youtube.com/watch?v=dQw4w9WgXcQIf the title prints without errors, you’re ready to start downloading.
Common Use Cases
- Download best‑quality video:
yt-dlp -f best URL - Extract audio only (MP3):
yt-dlp -x --audio-format mp3 URL - Save subtitles:
yt-dlp --write-subs --sub-lang en URL - Batch download from a list: place URLs in
list.txtand runyt-dlp -a list.txt
Handling Permissions and Storage
Termux runs in its own sandbox, so writing files to the shared Android storage requires explicit permission. Grant access with:
termux-setup-storageAfter confirming, you can direct output to the shared folder, for example:
yt-dlp -o /storage/emulated/0/Download/%(title)s.%(ext)s URLTroubleshooting Tips
- Missing SSL libraries? Re‑install
openssl-toolviapkg install openssl-tool. - “Permission denied” on execution? Double‑check the
chmod +xstep and that the binary lives in a directory listed inPATH. - Site‑specific errors? Run
yt-dlp -Uto pull the newest patches; many breakages stem from upstream changes.
Keeping yt‑dlp Up to Date
Because video sites tweak their APIs regularly, staying current matters. The simplest approach is:
pip install -U yt-dlpIf you cloned the repository, pull the latest changes and reinstall:
cd yt-dlpgit pull
python -m pip install -U .
Wrapping Up
With Termux and yt‑dlp on your device, you’ve essentially built a pocket‑sized media library manager. The steps above may feel a bit technical, but once the setup is done, downloading content becomes a matter of typing a short command. Explore the myriad options in yt-dlp --help and tailor the tool to your workflow—whether you’re archiving lectures, grabbing music, or simply keeping a favorite clip handy for offline viewing.