0

I actually have three questions:

  1. So I was trying to switch between python2.7 and python3.4. I added both the alternatives using update-alternatives, giving priorities 1 and 2, respectively. It was set to manual mode so I configured it and tried running python. I don't know what happened here but it didn't work. It was working fine before setting the alternatives. But, instead, when I entered python2 it worked just fine and launched python2.7. Similarly, entering python3 launched python3.4. And this got me confused a bit.

    Isn't python supposed to be a generic command to run either v2.7 or v.3.4 based on the configuration?

  2. Now, very gallantly, I tried fixing this on my own, without feeling the need to look up what the problem was (naive, I know). I played around with it a bit. Removed the alternatives one-by-one using remove ( should've used remove-all sighs ) but, suspiciously enough, when I ran update-alternatives --list python, it still was showing the alternatives. Confusion++.

    What's the reason behind this? Why were those still being shown?

  3. Anyway, assuming they were removed, I added the alternatives again and, in the hope of having fixed the problem, tried running python. Alas, it didn't work... displaying the following line:

    bash: /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: No such file or directory

    Next, tried running python2. Bam! This time, this one didn't work either! Producing a similar output:

    bash: /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: No such file or directory

    Same for python3. Output:

    bash: /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: No such file or directory

    So, what am I missing here and where lies the problem? Please elaborate.

PS : Pardon my ignorance. The questions might be silly but It's only recently that I started learning all this. I am pretty much a noob.

PPS : I am running Xubuntu 15.04.

TIA.

3
  • 1
    Please don't cross-post questions. meta.stackexchange.com/questions/64068/…
    – bwDraco
    Oct 17, 2015 at 23:19
  • Protip. Do not ever mess around with python. Your package manager and other things are dependent on it, and python 2 and 3 are very different snakes. "python" is always python 2. "python 3" is always python 3. What's the output of which for the three commands?
    – Journeyman Geek
    Oct 17, 2015 at 23:29
  • @JourneymanGeek Nothing. It shows nothing. The next prompt appears. That's all. Oct 22, 2015 at 11:59

1 Answer 1

0

Isn't python supposed to be a generic command to run either v2.7 or v.3.4 based on the configuration?

No  no no no  noooooooooooooooooo

Here's what's basically the case. Python 2 and 3 are different and very distinct runtimes and languages, and the system will always assume python is python2, and python3 is python3. This is since many system critical applications rely on python, and are old enough to call "python" over "python3".

When writing your own apps, call the appropriate interpreter, rather than assuming.

I'm not sure what you've broken but it feels a lot like python 2/3 are stored elsewhere, and your actions broke the symlink (which is what alternatives does).

We don't know what else is broken, so it may be an excellent idea to back up all that you hold dear, rebuilt the system and not taunt the serpent until you have a better idea of what you're doing. A developer, or even a sysadmin typically would not need to do what you tried.

If you need to use other versions of python, consider virtualenv

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .