4

I am having no luck getting youtube-dl installed on my 20.04 system. Here's what I have tried:

  1. sudo apt-get install youtube-dl

    RESULT: The command executes OK, but when I try to download anything I get errors. I checked the version:

    $ youtube-dl --version
    2020.03.24
    $ which youtube-dl
    /usr/local/bin/youtube-dl
    

    I assume I got an old version of youtube-dl because Ubuntu's repo is out-of-date?

So, searching for solutions led me to try this:

  1. pip3 install --upgrade youtube-dl

    This attempt being a highly up-voted answer here on SE.. But first - removed the apt-installation using sudo apt-get remove youtube-dl

    But when I check to verify the version, I remain stuck at the old version!

    $ youtube-dl --version
    2020.03.24
    

    So let's move that out before trying something else:

    $ pip3 uninstall youtube-dl
    Found existing installation: youtube-dl 2020.11.26
    Uninstalling youtube-dl-2020.11.26:
      Would remove:
        /home/walker/.local/etc/bash_completion.d/youtube-dl.bash-completion
        /home/walker/.local/etc/fish/completions/youtube-dl.fish
        /home/walker/.local/lib/python3.8/site-packages/youtube_dl-2020.11.26.dist-info/*
        /home/walker/.local/lib/python3.8/site-packages/youtube_dl/*
        /home/walker/.local/share/doc/youtube_dl/README.txt
        /home/walker/.local/share/man/man1/youtube-dl.1
    Proceed (y/n)? y
      Successfully uninstalled youtube-dl-2020.11.26
    

    Whoa!? I just un-installed the current version!

  2. sudo snap install youtube-dl

    Aka "Method 2" from this website, which went as follows:

    $ sudo snap install youtube-dl
    youtube-dl 2020.11.17+gitd65d891 from Joe Borg (joeborg) installed
    $ youtube-dl --version
    bash: /usr/bin/youtube-dl: No such file or directory
    $ which youtube-dl
    /usr/local/bin/youtube-dl
    

Which leaves me confused and bewildered beyond repair. I have used youtube-dl for over a year now & installed on macOS & Debian systems - with no problems. I know Ubuntu is different, but... this is confusing.

How do I fix this?

  • youtube-dl is a 'universe' or Community Supported package. It gets updated only when a user detects issues, and files a bug on it (I've done it in the past, usually it's fixed within a day or two, but it'll depend on the volunteers time availability). My own Ubuntu has 2020.11.21.1 according to youtube-dl --version installed, but I'm not on focal. In your case I'd file a bug (ie. request to update).. but it's up to you (updates occur regularly due to google's constant changes). – guiverc Nov 29 '20 at 1:36
  • 1
    Refer to Gunnar's answer. That is faster, and doesn't require the bug report, plus consequential re-packaging work for the community member (volunteer) who packages it in their own time.. I've done that too on many older releases – guiverc Nov 29 '20 at 1:58
  • alternative that , alas , uses a third party in your browser is loader.to. works for bitchute, brandnewtube etc – pierrely Dec 1 '20 at 5:24
7

If you install the youtube-dl package from the 20.04 Ubuntu archive, it does not result in any /usr/local/bin/youtube-dl file. So probably you have previously installed youtube-dl in some other way than one of the ways you mention in your question, and that may be the cause of the confusion.

If you don't remember how that happened, I would suggest that you simply delete that file:

sudo rm /usr/local/bin/youtube-dl

The pip3 way is a good way to get the latest available version. Please note though, that if you install via pip3 as your own user (i.e. without sudo) the youtube-dl executable will end up in $HOME/.local/bin, and you may need to log out and log in again to make that directory be included in PATH.

  • 3
    @deWalker: As guiverc pointed out in a comment, the package is maintained by a volunteer. I would rather ask: Why is youtube-dl in the Debian/Ubuntu archive at all? Considering how often it is updated, it doesn't fit well for distros with a high barrier for updating packages in stable releases. – Gunnar Hjalmarsson Nov 29 '20 at 2:35
  • 1
    @GunnarHjalmarsson for your last sentence, it is sufficient to just close and reopen the terminal to have .local/bin included in the path. ~/.profile is sourced each time you open a terminal. – vanadium Nov 29 '20 at 12:23
  • 3
    @delWalker: Just as a general hint: If you see something in /usr/local, it never comes from Ubuntu. The whole point of that directory is that it is "owned" by the local sysadmin (for personal / home use that person is usually identical with the user), and will never be touched by the distribution. Hence the name "local". – Jörg W Mittag Nov 29 '20 at 16:17
  • 1
    @GunnarHjalmarsson: Got enough rep to upvote, so thanks again. – deWalker Nov 29 '20 at 19:02
  • 1
    @Seamus: The code for adding ~/.local/bin to PATH is in ~/.profile, so sourcing ~/.profile may be an option. But even if there is more than one way to do it, I think that relogin is a reasonable advice in the answer we are discussing here. – Gunnar Hjalmarsson Dec 2 '20 at 0:37
3

An alternative solution:

Background:

There are installation instructions on yt-dl's GitHub site that effectively download a copy of the latest version of youtube-dl to /usr/local/bin - they are simple enough even I could follow them.

But that leads to another problem - possibly an Ubuntu problem, a Python problem or a youtube-dl problem... I don't know whose problem it is, but here's the problem. After following the yt-dl installation instructions, try to check the version:

$ youtube-dl --version
/usr/bin/env: ‘python’: No such file or directory

As I understand this, it just means that the system (Ubuntu) and youtube-dl cannot resolve where Python is installed. But I know I do have Python3 installed:

$ which python
$ which python3
/usr/bin/python3

And since I did not install Python3, this seems to mean that Ubuntu 20.04 came with Python3 installed, but Python(2) was not installed.

Solution 1:

$ sudo apt-get install python-is-python3

Check/verify solution:

$ youtube-dl --version
2020.11.29

So this has been tested & verified on my system - FWIW.

Solution 2:

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode

Verify this works (after removing the previous solution 1):

$ youtube-dl --version
2020.11.29

Credits to @mighty9245 for this solution.

Addendum:

Personally, this manual installation solution works best for me as I have no interest in becoming entangled in all of the Pythonic minutae; virtual environments and other artifacts. And while it's disappointing that Ubuntu's repo can do no better than a version of youtube-dl that's 8 months old, this installation procedure does have one advantage over the apt repo:

A manual installation of youtube-dl allows one to update directly and immediately via:
sudo youtube-dl -U.


From the Focal Fossa Release Notes:

Python3 by default

In 20.04 LTS, the python included in the base system is Python 3.8. Python 2.7 has been moved to universe and is not included by default in any new installs.

Remaining packages in Ubuntu which require Python 2.7 have been updated to use /usr/bin/python2 as their interpreter, and /usr/bin/python is not present by default on any new installs. etc, etc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.