thumb

Recently, when attempting to use a youtube-dl tool in the Terminal app, I saw an error message saying /usr/bin/env: ‘python’: No such file or directory. In this tutorial, you will learn how to fix the error that leads to this error message.

What causes this error

In my case, the below error appeared when attempting to run the youtube-dl tool in the Terminal app on my MacBook with Ubuntu 20.04 LTS.

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

The error message above is self explanatory. It saying that the system cannot find the python binary file.

We can run the following simple command to determine that the python (it’s actually named python3, where 3 is the version number) package is installed in the system:

whereis python3
python3: /usr/bin/python3 /usr/bin/python3.8 /usr/lib/python3 /usr/lib/python3.8 /etc/python3 /etc/python3.8 /usr/local/lib/python3.8 /usr/include/python3.8 /usr/share/python3 /usr/share/man/man1/python3.1.gz

In my case, I see that the python3 package is already installed. Therefore, something is wrong with the system paths, so the system cannot find its binary file.

If in your case there is no output at all, then you do not have python3 installed.

Now we know what caused this error.

How to solve it

Once we know what is causing this error message to appear, we can use it to solve the problem. It is a really easy process. To solve this problem, we need to install the python3 package, if it is not already installed, and create a symlink to it. Now, step by step guide.


Launch your terminal app. As a terminal app, I use the Terminal app that is shipped with Ubuntu, but you can use any other terminal app.


In the terminal, type the following commands and press the Enter key to install the python3 package, if it is not already installed.

Note! Ubuntu 20.04 and other versions of Debian Linux ship with Python 3 pre-installed.

sudo apt update
sudo apt install python3

When prompted, type your computer administrator password and press the Enter key.

Note! Terminal doesn’t show any characters as you type your password. This is normal Terminal behavior.


Now, type the following command and press the Enter key to create a symlink from “python” to “python3”.

sudo ln -s /usr/bin/python3 /usr/bin/python

Conclusion

That’s it, you’re done. Now the /usr/bin/env: ‘python’: No such file or directory error should be gone. So simple isn’t it?

If you are having trouble fixing this problem with the instructions above, but are being able to solve this problem with any another method please describe it in the comment section below. Thanks!

I hope this article has helped you learn how to fix the /usr/bin/env: ‘python’: No such file or directory error. If this article has helped you then please leave a comment :smiley:

Thanks for reading!