Skip to content Skip to sidebar Skip to footer

Python 2.7.5 And Python 3.6.5

I have installed Python 3.6.5 however when i type Python it shows Python 2.7.5. Id like to use Python 3. [aravind@aravind05 Python-3.6.5]$ python3 --version Python 3.6.5 [aravind@

Solution 1:

There are multiple ways to achieve this.

Assuming you are on some *NIX OS using a bourne-shell-like shell, you could define an alias alias python python3.

You could also place a symlink named 'python', pointing to python3 into a directory that is listed earlier in your PATH:

# on debian-like distributions, the following directories should be reasonable
ln -s ~/.local/bin/python "$(which python3)"
# place the following line into your .bashrc
export PATH="~/.local/bin/python:$PATH"

Solution 2:

Like Klaus stated in a comment, changing your system Python version might break system stuff.

Instead, use virtualenv. Here is a very well explanation if you need help with it.


Solution 3:

Since you have both versions of Python installed in your system, you need to direct your default Python to Python 3.x. You can do that by adding a few lines to your .bashrc file.

Open your .bashrc file nano ~/.bashrc. Type alias python=python3 on to a new line at the top of the file then save the file with ctrl+o and close the file with ctrl+x. Then, back at your command line type source ~/.bashrc. Now your alias should be permanent.

EDIT:

For update alternatives, the priority is an integer. The priority represents which program should be the first used. This article sums it all up pretty well.

Here is the related question: https://stackoverflow.com/a/41986843/4982185


Post a Comment for "Python 2.7.5 And Python 3.6.5"