5

I did a mistake. I installed Python 3 and then I did the following command in order to have the defaut version Python as Python3

sudo ln -fs /opt/Python-3.4.1/python /usr/bin/python

But I wanted to come back to the python2.7 and I did

sudo ln -fs /usr/bin/python2.7/python /usr/bin/python

Now, When I want to run a bash script with python inside, I have this following error:

/usr/bin/env: bad interpreter: Not a directory

When I run this command:

ls -l /usr/bin/env

I have this result in red:

lrwxrwxrwx 1 root root 25 Jun 12 13:37 /usr/bin/env -> /usr/bin/python2.7/python

Indeed, when I go in this directory, I don't have the env executable anymore but a broken link.

I didn't find a solution on the internet.

Could you help me ? I begin to feel bad about my mistake.

Thanks

lilouch
  • 1,054
  • 4
  • 23
  • 43
  • 1
    Related: http://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script Do not link `env` to actual `python` version, this program has special purpose (see related Q) – myaut Jun 12 '15 at 05:54
  • 1
    Yes It was a mistake. I saw this post but how I can fix it ? – lilouch Jun 12 '15 at 05:57
  • Messing with `/usr/bin` is an absolute no-no on basically every modern platform. – tripleee Sep 08 '19 at 11:33

1 Answers1

7

Okey, I solved my issue by reinstalling this env file.

sudo apt-get install --reinstall coreutils

Then thanks to this post in Why do people write the #!/usr/bin/env python shebang on the first line of a Python script? I know better how to switch between version and do not do the same mistake anymore.

LHeng
  • 531
  • 5
  • 9
lilouch
  • 1,054
  • 4
  • 23
  • 43
  • 1
    Thank you thank you so muhch, I am not a geek in Unixoid systems and it took me almost a whole day to figure it out that somehow I have deleted this file and I had no clue that this is part of core utils of Ubuntu 20.04, you saved me a lot of time waste, it worked and now npm -v gives the version and it works, before I tried installing and removing using default repositories, then NVM and nothing worked until finally this. Great to learn something new every day. – Sergey Kravchenko Feb 07 '22 at 13:08