0

I have set alias python=python3.4. but still when I write python in terminal it executes as version 2.7.

python3.4 only works in the terminal window where alias python=python3.4 is set.

Please help.

Thanks in advance.

1 Answer 1

3

Setting an alias is essentially a user shortcut and does not affect your environment outside of your terminal(see description of 'alias' here). Your question doesn't explain what the 'end goal' is, so I'll answer the two I can think of.

  1. If you only interested in a shortcut:Don't do it! Just use 'python3.4' - it's 3 more keystrokes...

  2. If you want to use version 3.4 by default outside your terminal:

First, you need to do is change the symlink of /usr/bin/python to point to the correct python version.

  unalias python
  ls -al $(which python)

Output should be something like:

lrwxrwxrwx 1 root root 9 Jan 01 00:01 /usr/bin/python -> python2.7

You need to change the link ("/usr/bin/python") to point to the python3.4 version:

sudo ln -f -v /usr/bin/python3.4 /usr/bin/python

IMPORTANT - you are changing the executable python version universally! Be sure you don't have any applications that depend on the older version's libraries. If, for example, you've installed the libpython2.7-dev package, then this is a CRAY CRAY BAD IDEA! Never mix versions of executables and build resources or you will get weird behavior...

You must log in to answer this question.

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