ytdl command not found

In this troubleshooting guide we learn how to fix ytdl command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

ytdl: command not found

or when using sudo you get the following error message

sudo: ytdl: command not found

Solutions to ytdl: command not found

How To Fix ytdl: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu ytdl is provided by python3-pafy package.

python3-pafy is:

Pafy is a Python library for interacting with YouTube from within your Python programs. Its main features include:

  • Retrieve metadata such as viewcount, duration, rating, author, thumbnail, keywords
  • Download video or audio at requested resolution / bitrate / format / filesize
  • Command line tool (ytdl) for downloading directly from the command line
  • Retrieve the URL to stream the video in a player such as vlc or mplayer
  • Works with age-restricted videos and non-embeddable videos
  • Small, standalone, single importable module file (pafy.py)
  • Select highest quality stream for download or streaming
  • Download video only (no audio) in m4v or webm format
  • Download audio only (no video) in ogg or m4a format
  • Retrieve playlists and playlist metadata

To fix this problem, we can install more using the command below.

sudo apt-get -y install python3-pafy

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install python3-pafy.

sudo apt -y install python3-pafy

Or if you have aptitude installed you can use the following command.

sudo aptitude install python3-pafy

Summary

In this tutorial we learn how to fix ytdl command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.