Research Computing Services Blog

  • Archive
  • RSS
  • Got a question? Let's talk.

How to install Python and which one to install?

Python Versions

Python has been transitioning from Python 2 to Python 3 for a ridiculously long time. This question was being asked in 2011 when I was wondering which version I should learn and what the difference actually was.

Currently Python 3 is probably your best bet, as most packages now support it and there are many improvements to the Python language in version 3.

That being said there are libraries that will only work in Python 2 and there is a huge amount of legacy code that has’t been transitioned yet. This might be especially true if you use specialist libraries in your work.

Another reason to use Python 2 is if you are doing the excellent Coursera course by Dr. Chuck which is being converted to Python 3 (I know this because I’m part of the open source project to do the conversion) but is still in Python 2.

For most people the difference between Python 2 and Python 3 comes down to how you print and what happens when you divide something. Printing now requires brackets around what you want to print - just like any other python function.

Python 3 Printing

name = 'Alistair'
print(name)
>>> Alistair

Python 2 Printing

name = 'Alistair'
print name
>>> Alistair

The other one, division, is integer division (where the remainder is discarded) in Python 2 and normal division in Python 3 (use ’//’ to do integer division in Python 3) if the numbers being used are integers. If at least one of the numbers is a floating point number (e.g. 1.5), the division is normal in both.

Python 3 division

answer = 10/3
print(answer)
>>>3.3333333333333335

Python 2 division

answer = 10/3
print(answer)
>>>3

So for anyone starting out with Python, the difference between the two versions is trivial and I’d suggest using Python 3 by default and Python 2 when you have to.

#Anaconda

Python 2 and Python 3 will live happily side by side on a computer but the Anaconda package manager will make this situation a whole lot easier and has many other benefits as well.

So I would suggest installing the Python 3 Anaconda and then setting up a Python 2 environment for when you need it.

Download the version for your OS here and follow the instructions. There is both a command line installer and a graphical installer, so choose whatever you’re most comfortable with.

To setup a second environment like a Python 2 environment, come down to #Hackyhour at Bar Tsubu @Unimelb Parkville campus and we’ll get you sorted out! The instructions are on the Anaconda site too.

    • #Python
    • #Alistair
    • #Python version
    • #hackyhour
  • 3 years ago
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+
← Previous • Next →

Portrait/Logo

About

Welcome to the Research Computing Services Blog. We're here to help you do your research better! We'll connect you with the best research tools, workshops, expertise & community. Need more information? Check out our pages below!

https://research.unimelb.edu.au/infrastructure/research-computing-services

Pages

  • About us
  • Sign-up for FREE researcher training HERE
  • ResPlat Training Catalogue
  • Calendar of Events and Trainings
  • CoLab: A New Collaborative Space for Researchers!
  • Mailing List
  • The Research Bazaar 2018
  • #MyResearch Video Campaign
  • Resbook

Me, Elsewhere

  • @ResPlat on Twitter
  • ResBaz on Youtube
  • ResBaz on Flickr
  • resbaz on github
  • ResBaz on Instagram
  • RSS
  • Random
  • Archive
  • Got a question? Let's talk.
  • Mobile
Effector Theme — Tumblr themes by Pixel Union