/usr/bin/python3: bad interpreter; how to make python3 work again?

Question:

I had two versions of python installed (python – 2.7.12 and python3 – 3.5.2). After installing python 3.7.7, I wanted to make it the default of the python3 command by making a few commands. But unfortunately, the python3 command no longer works!

fogang@FF:~$ python
Python 2.7.12 (default, Oct  8 2019, 14:14:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
fogang@FF:~$ python3.7
Python 3.7.7 (default, Mar 10 2020, 17:25:08) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
fogang@FF:~$ python3
bash: /usr/lib/command-not-found : /usr/bin/python3 : mauvais interpréteur: Aucun fichier ou dossier de ce type
fogang@FF:~$

Translated: “/usr/bin/python3: bad interpreter: No file or folder of this type”

There is my /usr/bin

fogang@FF:/usr/bin$ ls python*
python     python2.7-config  python3.5-config   python3.7         python3.7m-config  python3m-config  pythontex3
python2    python2-config    python3.5m         python3.7-config  python3-config     python-config
python2.7  python3.5         python3.5m-config  python3.7m        python3m           pythontex
Asked By: K.J Fogang Fokoa

||

Answers:

/usr/bin/python3 is missing. Based on the comments, you’re using Ubuntu, so the solution is to simply reinstate it:

sudo ln -s python3.5 /usr/bin/python3

Note that changing the system python3 version on Ubuntu will break things, so the better solution is to use an alias, e.g. put alias python3="python3.7" in your bashrc.

Answered By: wjandrea

This is a similar error I received:

usr/local/bin/ranger:17: /usr/local/bin/ranger: bad interpreter:
/usr/local/opt/[email protected]/bin/python3: no such file or directory

I have multiple versions of python installed (3, 3.10, and 3.11 specifically). Our errors are both saying that the file expected is missing or unavailable. So I created a symlink and that fixed my issue.

ln -s /usr/local/opt/[email protected]/bin/python3 /usr/local/opt/[email protected]/bin/python3

Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.