1

So I'm starting out with python. I'm working on a laptop with a fresh install of fedora25.

I got everything running in eclipse with pydev, but per directions of the instructor I need to use python 3.4 or newer.

So I check what version I'm using. Aparently it's python 2.7.13 I thought fedora post 23 used python3 by default, but such is life. So I check here and askfedora and other sources for how to change default version when you have more than one installed. And two of them suggest How to switch between Python versions on Fedora Linux. Before blindly throwing anyone's suggestion into a shell I browse around and it looks like a pretty good site.

So I followed the tutorial, and now NOTHING python related works.

$ alternatives --list | grep -i python
((no output))
$ sudo alternatives --install /usr/bin/python python /usr/bin/python3.4 2
$ sudo alternatives --install /usr/bin/python python /usr/bin/python2.7 1
$ alternatives --list | grep -i python
python auto /usr/bin/python3.4
$ python -v
bash: /usr/bin/python: No such file or directory
$ python -V
bash: /usr/bin/python: No such file or directory
$ python --vesion
bash: /usr/bin/python: No such file or directory

It looks like creating the symlinks as directed broke the connection between the expected python source /usr/bin/python and everything that tries to access it. I'm sure there's an "easy" fix, but I have no idea what it could be. Help, please and thank you.

I thought using alternatvies changed the python to a set of symlinks and you had to set one (see code block below).

$ alternatives --config python

There are 2 programs which provide 'python'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/bin/python3.4
   2           /usr/bin/python2.7

Enter to keep the current selection[+], or type selection number: 
$

So why are none of them set to "answer" when something tries to follow python?

So I got out of the shell and used gui Files under Activities. Went to /usr/bin. Found python. Tried clicking on it; I get this error message: The link "python" is broken. This link cannot be used because its target "/etc/alternatives/python" does not exist.

I don't want to set the link to point at one or the other python, right? That's the point of alternatives, isn't it?

  • What /usr/bin/python currently links to? And what that thing links to as well. i.e. when you follow all the soft links where does it end? Probably a broken soft link on the path. The syntax is alternatives link name path, so does /usr/bin/python3.4 and /usr/bin/python2.7 actually exist? – grochmal Feb 9 '17 at 1:46
  • So I got out of the shell and used gui Files under Activities. Went to /usr/bin. Found python. Tried clicking on it. And I quote: The link "python" is broken. This link cannot be used because its target "/etc/alternatives/python" does not exist. So entering those alternative commands busted something. – TK421 Feb 9 '17 at 4:59
6

Don't do this. Since Python 2 and Python 3 are not compatible, they're not good candidates for the "alternatives" mechanism. Too many packages assume that /usr/bin/python is Python 2, and a lot of stuff will break.

Since a lot of software is not ready to move to Python 3, Fedora couldn't just switch everything over. Instead, we decided to leave /usr/bin/python as Python 2. Python 3 can be installed in parallel and is found at /usr/bin/python3. Fedora 25 includes Python 3.5, so this should be sufficient for your class.

Just make sure to use #!/usr/bin/python3 at the top of your files and to use python3 at the command line.

  • (Also, ln -sf python2 /usr/bin/python to put the symlink back to how it was.) – mattdm Feb 9 '17 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.