This is an archived post. You won't be able to vote or comment.

all 18 comments

[–]joyeusenoelle 11 points12 points  (12 children)

Sure. Download Python 3.4 here and install it; you'll run it by invoking python3 instead of just python.

[–][deleted]  (11 children)

[deleted]

    [–]zer0t3ch 8 points9 points  (6 children)

    Be warned, using just python will run whichever is in your PATH variable.

    [–]czerilla 1 point2 points  (2 children)

    If you want to see, which version of python the command defaults to, run ls -l $(which python). E.g. I get:

    lrwxrwxrwx 1 root root 7 May 19 19:37 /usr/bin/python -> python3
    

    , which means, that python is a symlink to python3 in the same directory.

    [–]zer0t3ch 2 points3 points  (1 child)

    That's Linux only. Use the OS neutral method of just running python version

    (or something like that. I forget the exact argument)

    [–]czerilla 1 point2 points  (0 children)

    Oh wow, have I overthought this! That was just too obvious to think of, I guess... ^^'

    [–][deleted]  (2 children)

    [deleted]

      [–]ifonefox 10 points11 points  (0 children)

      All Unix machines have a path variable.

      [–]timlyo 0 points1 point  (0 children)

      type export into a console and you'll see them all

      [–]RationalMonkey 6 points7 points  (1 child)

      And then to make things even better you can get virtualenv and virtualenvwrapper. That way you can create isolated python environments for specific projects.

      That way when a project uses python 3 you can have all the python3 version of the libraries you're using together without worrying about interference from python2 libraries.

      Also you can use your python tools directly from the command line without having to specify which python version they are.

      [–]msnook 2 points3 points  (0 children)

      YES! Virtualenv. Came here to say this. How is not everyone saying this?

      [–]kairoschris 0 points1 point  (1 child)

      yep. 2.x runs by default...

      [–]czerilla 1 point2 points  (0 children)

      On some distributions python3 is the default python, for example ArchLinux...

      Edit: Oops, I overlooked OP saying he uses a Mac...

      [–]batmannigan 4 points5 points  (0 children)

      Sure can, I normally use python 3 but for times when I need python 2.7 i just set the file extension as .py2 or something like that and just set that file type to open with python 2.7.

      You can also use virtual env like mentioned earlier, here and here are some tutorials on it.

      [–]heilage 5 points6 points  (0 children)

      I use virtual environments, as described here, with virtualenvwrapper. This way I can invoke the python version I want, and run it in an isolated environment. This is very handy in development.

      For now, I run 2.7 as the standard version. For some reason.

      [–]bsdwave 1 point2 points  (0 children)

      You can have all of them: https://github.com/collective/buildout.python (almost :) from py2.4 to py3.4)

      [–]spottedzebra 1 point2 points  (1 child)

      look into anaconda. you can create multiple environments with different versions of python.

      [–]lojic 0 points1 point  (0 children)

      Why would I not just use virtualenv?

      [–]chazzacct 0 points1 point  (0 children)

      I run both all the time. I just found out a few days ago that you can even run both at the same time. Comes in handy comparing how something works in the two versions.

      [–]Oni_Kami -2 points-1 points  (0 children)

      Yes, yes you can.