2

I have python3 installed on Ubuntu 20.04, and I have an application that needs python 2.7 installed. After installation of python 2.7 it looks like python cannot be found

 /usr/bin/python: bad interpreter: No such file or directory 

which python, which python2 and which python3 do not return any results

Here's the content of /usr/bin:

root@ip-10-10-10-201:/home/ubuntu# ls -alh /usr/bin/pyt* lrwxrwxrwx 1 root root 9 Mar 13 2020 /usr/bin/python2 -> python2.7 -rwxr-xr-x 1 root root 3.5M Aug 4 11:16 /usr/bin/python2.7 lrwxrwxrwx 1 root root 9 Mar 13 2020 /usr/bin/python3 -> python3.8 lrwxrwxrwx 1 root root 16 Mar 13 2020 /usr/bin/python3-config -> python3.8-config -rwxr-xr-x 1 root root 5.3M Jul 28 12:59 /usr/bin/python3.8 lrwxrwxrwx 1 root root 33 Jul 28 12:59 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config 

I'm not sure how to get this working, if I need both pythons (2.7 and 3.8) to be working. Should I change the #!/usr/bin/python in the scripts that require phyton2 to #!/usr/bin/python2 ?

Will appreciate your help. Happy holidays!

9
  • Start a new shell or reloading your profile may do it source ~/.bash_profile Commented Dec 22, 2020 at 18:30
  • Do you see a file named exactly /usr/bin/python in this output from ls? In order to use the correct interpreter, you should specify a path to the existing executable. Thus, you can use /usr/bin/python2 or /usr/bin/python2.7. The shebang normally looks like #!/usr/bin/env python. Commented Dec 22, 2020 at 18:31
  • Does this answer your question? : bad interpreter: No such file or directory in python Commented Dec 22, 2020 at 18:33
  • Relevant: askubuntu.com/questions/1296790/… To get python, you have to explicitly choose between python-is-python2 or python-is-python3. Commented Dec 22, 2020 at 18:35
  • 2
    Keep in mind, though, that just because you link /usr/bin/python to one or the other, that doesn't mean it's correct for any arbitrary script that specifies /usr/bin/python. It's probably better to update the script to be explicitly. Commented Dec 22, 2020 at 18:46

1 Answer 1

2

As suggested by @ForceBru, changing the scripts from /usr/bin/python to /usr/bin/python2 seems to work.

This is due to the fact that Ubuntu Python packages are always coming as python2 and python3, not python.

Sign up to request clarification or add additional context in comments.

1 Comment

You should be able to mark this as the Answer now to close your Question!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.