Ask Ubuntu Asked by Geoff Langenderfer on December 8, 2021
In Ubuntu 20.04, we get the following error:
❯ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal
❯ youtube-dl https://www.youtube.com/watch?v=b4mihzeFqGA
/usr/bin/env: ‘python’: No such file or directory
How can I fix it?
If you don't need python 2 and only need python 3, the easiest is to just
sudo apt install python-is-python3
It's actually just a symlink. The package description explains it:
In Ubuntu, all python packages use explicit python3 or python2 interpreter and do not use unversioned
/usr/bin/python
at all. Some third-party code is now predominantly python3 based, yet may use/usr/bin/python
.This is a convenience package which ships a symlink to point the
/usr/bin/python
interpreter at the current defaultpython3
. It may improve compatibility with other modern systems, whilst breaking some obsolete or 3rd-party software.
Answered by mivk on December 8, 2021
The python
variable is not set and update-alternatives
will not work either. Let's fix that.
Afterwards, we can decide which version python
points to using $ sudo update-alternatives --config python
.
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 2
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 3
$ sudo update-alternatives --list python
/usr/bin/python2
/usr/bin/python3
$ sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/python3 3 auto mode
1 /usr/bin/python2 2 manual mode
2 /usr/bin/python3 3 manual mode
Press <enter> to keep the current choice[*], or type selection number:
$ python --version
Python 3.8.5
Answered by Daniel on December 8, 2021
This works for ubuntu 20.04 LTS:
nano $(which youtube-dl)
and then replace the first line (the shebang line i.e. #!...) with
#!/usr/bin/python3
Answered by Matteo Paolucci on December 8, 2021
The easiest way to deal with this in Ubuntu 20.04+ is to symlink python to python3:
sudo ln -s /usr/bin/python3 /usr/bin/python
Note, however, that if you install other Python programs that rely on the older version of Python, they may not run or work correctly until you remove the symlink and install the older version of Python, or fix the programs to use Python 3. But the older Python version is no longer supported, so it would be better to use only Python programs that can run under Python 3 in the first place.
Answered by UbuntuUser on December 8, 2021
I had the exact same problem trying to install youtube-dl in ubuntu 20.04 and spent a long time trying to resolve. On the verge of giving up, I saw this from Canonical and thought it looks too simple but tried it anyway! Problem solved!
sudo snap install youtube-dl
Answered by Andy on December 8, 2021
I think python is missing on your system so,
First of all check if you have python installed .
To check this simply open terminal and type python
. If it shows python version and prompt then quit by typing quit()
And if python is missing then install it with this command :
sudo apt-get install python3
If that does not help, then try this command:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1000
Answered by Prabhakar Prakash on December 8, 2021
In Ubuntu 20.04, python3
is the installed default. The python
variable is not set:
❯ which python
python not found
We can get around this by using python3
and which
:
❯ python3 $(which youtube-dl) https://www.youtube.com/watch?v=0IE-CXNs6Sw
[youtube] 0IE-CXNs6Sw: Downloading webpage
Answered by Geoff Langenderfer on December 8, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP