Setting up a Python environment

In this course, we will be using python 3. The latest python version, as of February 2019, is 3.7. It is not necessary to have the latest version: Any version of from python 3.4.x should be sufficient. However, some of the modules we occasionally use may have new features in newer versions.

Here, we provide some guidelines for how to install python 3 on your own computer. Keep in mind, though, that lecturers and tutors are NOT able to provide technical support for problems with your personal computer.

Installing Anaconda Anaconda Package Management
Installing core Python package (not recommended) Text Editors

We highly recommend using the Anaconda python distribution. Why?

  • It is the same one that is installed on the CSIT lab computers and the InfoCommons computers, so everything will look familiar.
  • It comes with not only the python standard library, but also a number of extra modules that we will be using; it also comes with the Spyder IDE.
  • And if that’s not enough to convince you, check this out.

Installing Anaconda#

A short video is available on the Course Wattle site describing how to download and install Anaconda Spyder.

Download the distribution here for the latest version. Easy!

Notes:

  • You need to select the python 3.8 version (we will not be using python 2 version)
  • Click Yes if you are asked to make Anaconda your default Python installation
  • Otherwise accept all of the defaults

Anaconda Package Management#

The default, complete installation of Anaconda should provide all the packages you need. If you choose to customise your installation, or if you later discover that you need some other package, Anaconda provides the highly effective conda tool to maintain organised and up to date packages. To update your installed packages:

  1. Open a terminal window
    • Windows users - search for cmd application or check this
    • Mac users - search for terminal app or check this
    • Linux users - help the Mac and Windows users
  2. Type conda update anaconda

Other useful conda commands are:

  • conda info
  • conda help

For more information, read the documentation here

You can also install the core Python implementation, available from python.org. We do not recommend this as your first option, however. Why you ask?

  • The core installation does not provide all packages that we will be using, since… well it is the core distribution.
  • Thus, you will be required to (painfully) install these packages by yourself, one at a time.
  • The core python distribution comes with the IDLE IDE, which is (by many) considered inferior to other IDEs, such as Spyder.

If you are still keen to it take on, the most important modules which constitute the scientific Python core are:

  • numpy defines the fundamental data structures (so called ndarrays, N-dimensional arrays), fast mathematical operations on these arrays, and other routines which are used in numerical computations (linear algebra and matrix operations, Fourier transform, random number generators etc).
  • scipy defines scientific computing routines (essentially, it is a Python port of classic routines, like Linpack, which were first developed for use with the Fortran programming language and are now regarded as a gold standard of numerical software); scipy fundamentally relies on numpy for the representation of core data structures (arrays).
  • matplotlib is a 2D (and some 3D) plotting (and some animation) library; it has a package pyplot which simplifies its usage.
  • ipython/jupyter is a advanced shell (command-line environment) for quick Python development, which can be executed in a stand-alone shell, like QtConsole, or run from within the Terminal system shell window. IPython/Jupyter can also be run in a browser, so called IPython/Jupyter notebooks; in which you can type in and execute code (Python statements), but also insert text and media (images, movies, audio). Latest notebooks can also incorporate programmable element called widgets, which provide an enhanced control over code execution (these widgets emulate features available in a commercial system Mathematica). IPython notebooks are often used as a format for presentation of research work, lecture course materials and even textbooks and monographs. Visit the web site A gallery of interesting IPython Notebooks, to see the tremendous ranges of available resources. An IPython notebook is stored in a file with .ipynb suffix; it can be open in a web browser (you need to launch the IPythone/Jupyter kernel first).
  • sympy is the package for symbolic computation (and also high-precision mathematics); it emulates the functionality of commercial products like Mathematica and Maple (and the open source Sage).
  • pandas provides high-performance, easy-to-use data structures and data analysis tools.
  • scikit-image, scikit-learn and statsmodels are three most widely used packages from a large set of Scikits, a collection of add-on packages for SciPy (they are hosted and developed separately from the main SciPy distribution).

You can install each of them in addition to your standard Python distribution by running the pip3 command on the command-line interface:

% pip3 install pkgname

To install a package on the system globally (for other users), it needs to be run with the administrator privileges:

% sudo pip3 install pkgname

Alternatively (to avoid unnecessary duplication of Python installations), you can start with installing Miniconda (like its “big cousin” Anaconda, it is available for all major OS platforms. The Miniconda distro contains only the standard Python plus the Conda manager). Once installed, conda tool can be used to install packages which you need: eg:

% conda install numpy

Text Editors#

If you are not using the Spyder IDE (that comes with Anaconda), you should install and learn to use use some modern programming editor, for example:

More details about different IDEs and editors are also given on the Lab 1 instructions page.

bars search times arrow-up