The head of the youtube-dl script has #!/usr/bin/env python
, meaning that it uses the "python" command.
Per https://www.python.org/dev/peps/pep-0394/
Distributions can choose include the python command linked to python2 or python3, not include the command at all, or allow the user/admin to configure it.
In debian-based installs, there are 3 main python packages:
- python (
sudo apt install python
)
- python2 (
sudo apt install python2
)
- python3 (
sudo apt install python3
)
The "python" package installs python version 2 and includes the "python" command (symlink /usr/bin/python -> /usr/bin/python2).
The "python2" and "python3" packages do not provide the "python" command.
This means that calling "python" from the CLI or a script will result in a "command not found" error.
If you're using these, you have to either:
- call the script using whichever version you like (
python2 /usr/local/bin/youtube-dl
or python3 /usr/local/bin/youtube-dl
) [Personally, I have alias youtube-dl='python3 /usr/local/bin/youtube-dl'
in my .bash_aliases]
- edit the youtube-dl script to use python2 or python3 (
sudo sed -i '1s/python/python2/' /usr/local/bin/youtube-dl
) or (sudo sed -i '1s/python/python3/' /usr/local/bin/youtube-dl
)
In the above, I prefer using the aliasing option since you leave the file alone and don't have to edit it every time the file gets updated
It's also possible to fix it by creating a symlink for /usr/bin/python, but that is not adviseable.
Command 'python' not found, but can be installed with: sudo apt install python3
sudo apt install python
sudo apt install python-minimal You also have python3 installed, you can run 'python3' instead.
So it seems, 18.04 LTS calls python3 instead of python by default. I am wondering whether this is intentional. YouTube-dl looks for python. Installing python2.7 fixes the issue
– jacobacci May 21 '18 at 06:57