-3

I recently downloaded version 3.4 and installed it but when I go to the command line and type python -V I get Python 2.7.6 How do I set python 3.4 as my default version.

Bodhidarma
  • 519
  • 1
  • 7
  • 25

2 Answers2

0

The first step to do is to find where is your python.

You can do it with which or where command (which for unix where for windows). Once you have this information you will know what is actually executed as "python" command. Then you need to change it for windows (i believe) you need to change the PATH variable in such a way that your python 3.4 will be found earlier then 2.6

For the unix you need to either do the same or link it in your package manager.

cerkiewny
  • 2,761
  • 18
  • 36
-1

You need to use python3 to use python 3.4. For example, to know version of Python use:

python3 -V

This will use python 3.4 to interpret your program or you can use the shebang to make it executable. The first line of your program should be:

#!/usr/bin/env python3

If you want python3 to be used when you type python on the terminal, you can use an alias. To add a new alias, open your ~/.bash_aliases file using gedit ~/.bash_aliases and type the following:

alias python=python3

and then save and exit and type

source ~/.bash_aliases

and then you can type

python -V

to use python3 as your default python interpreter.

Vaibhav Mule
  • 5,016
  • 4
  • 35
  • 52
  • 1
    this hardly answers the question – cerkiewny May 22 '15 at 15:39
  • 1
    looks a bit better now but it is not a proper way of doing things, you should manage it either with your package manager (using something like brew link python3) or with path variable. – cerkiewny May 22 '15 at 15:44
  • it is community wiki, you can add if you want because I tried best to answer I feel doing proper way comes after making it work. – Vaibhav Mule May 22 '15 at 15:46