close

[Solved] bad interpreter no such file or directory /usr/bin/python

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error bad interpreter no such file or directory /usr/bin/python in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How bad interpreter no such file or directory /usr/bin/python Error Occurs?

Today I get the following error bad interpreter no such file or directory /usr/bin/python in python.

How To Solve bad interpreter no such file or directory /usr/bin/python Error ?

  1. How To Solve bad interpreter no such file or directory /usr/bin/python Error ?

    To Solve bad interpreter no such file or directory /usr/bin/python Error The problem is with your python installation. Probably your /usr/bin/python either does not exist at all or it is a dead symbolic link pointing to non-existing python.

  2. bad interpreter no such file or directory /usr/bin/python

    To Solve bad interpreter no such file or directory /usr/bin/python Error The problem is with your python installation. Probably your /usr/bin/python either does not exist at all or it is a dead symbolic link pointing to non-existing python.

Solution 1

The problem is with your python installation. Probably your /usr/bin/python either does not exist at all or it is a dead symbolic link pointing to non-existing python.

So first solution is to check if /usr/bin/python exists. If so check if it’s not dead link and if it is, fix the link to point to existing python intepretter:

cd /usr/bin
sudo ln -fs <full_path_to_existing_python_binary> python

If you can’t or don’t want to change /usr/bin/python but you have python installed and its location is recognized by the system (i.e. calling python from shell works) you can try changing your script as a workaround:

#! /usr/bin/env python
print("worked")

This way your script will use python as an interpreter regardless of the real python location as long as it is in your PATH.

Solution 2


I had similar problems, I had installed a package in my Ubuntu 20.04 which depended on Python 2. This messed up the meaning of python. I had to uninstall that package: qjoypadxboxdrv and one other; uninstall python 2 with sudo apt remove python.

Then to confirm, I used which python which gave a blank output. The next step was to cd /usr/bin and then create a symlink with sudo ln -fs python3 python.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read