Installing Python - cogeorg/teaching GitHub Wiki
Python will be our language of choice in this course and will greatly complement what you have learnt existingly in R. Using Python you will be introduced to the object-oriented programming paradigm.
Python versions
Before installing Python, we need to speak about versions. In this course we’ll make use of Python 3. Anyone with previous Python experience may choose to work in the version of their choice, but this comes with the explicit understanding that the responsibility of solving any errors or bugs that arise due to version conflict, lies with you, the student. Also, the PCs in the labs at UCT currently have Python 3.6.3
Python distributions
In addition to versions of Python, we can also distinguish between different distributions of Python. Instead, of simply downloading the base version of Python, one could download a specific distribution of Python, which simply refers to a build of Python that is packaged in a certain way, for specific purposes. In this case, a distribution of Python refers to installing a version of Python which is bundled together with a range of libraries or utilities that may be of use.
For this course, we’ll make use of the Anaconda distribution of Python, the best-known and most widely known distribution. As opposed to downloading the latest version of Python, we download the Anaconda distribution of Python, which comes bundled with a number of popular data science libraries and some other useful utilities, namely Jupyter Notebooks, which we’ll touch on later.
Anaconda can be downloaded for Windows, Linux and Mac from the Anaconda website here. I would suggest following the excellent documentation on the Anaconda website for installation on Windows, MacOS and Linux. If you ever need to remove Anaconda, find some help here.
Once you’ve got everything setup you can verify the version of Python by typing
$ python --version
In your command line / terminal
Choosing an IDE
An integrated development environment (IDE) simply provides an interface for the development of code. During your earlier courses, you learnt how to code in R, using RStudio. R is the programming language and RStudio is the IDE. Unlike the R domain where RStudio is the dominant IDE, Python has more options and developers are very different in the preferences they have for coding. These could be text editors like Sublime Text or Notepad +++, which can be configured from scratch, Python specific IDEs, such as PyCharm or cross-language IDEs, such as VisualStudio
In addition to these IDEs, notebooks represent a web application based interface to develop and deploy Python code, that runs on a server-client basis. Specifically, Jupyter Notebooks provide a self-contained environment for Python in your web browser for you to play around in. These notebooks allow you to imbed code, output and text (in the form of html) - think RMarkdown. Also, Jupyter Notebooks come pre-installed with your Anaconda distribution of Python.
For the first part of this course we’ll work in Jupyter Notebooks. In the later parts of the course, we’ll move to a text editor / IDE (the choice is yours), but more on that later. For now, just get used to working in Jupyter Notebooks. The official website explains how to launch a notebook but neglects to mention that an alternative way of doing this, involves simply opening up Anaconda, by clicking on the Anaconda Navigator icon, in the destination where you installed it, and opening Jupyter from there by clicking on the icon. Also find some more info about the Notebook interface here. When you’re ready to actually run code, the official website also has a walkthrough. If you're still struggling to get to grips with Jupyter Notebooks, DataCamp have another great guide, here.