Setting up a Python environment

Please ensure that you have followed the instructions on the Installing Anaconda and Testing your Anaconda Installation sections below.

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

The following is our recommended guideline for installing python 3 on your own computer.

Advanced users:

You are free to install python 3 in any way you prefer are not required to follow this guide for the course. Note however that lecturers and tutors will not in general be able to provide technical support for any problems you may face in, or as a result of, doing so.

Our recommendation is that you install the latest Anaconda python distribution which includes the Spyder IDE which is available as a single package here

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.

Choosing an IDE#

An Integrated Development Environment, or IDE, for python combines a text editor (for writing programs) with a python shell (interpreter), and some helpful functions to integrate the two.

There are a variety of IDEs available in both the CSIT labs/InfoCommons computers and for download online. You will need to learn to use one of them. (Or, can also use a stand-alone text editor, and the python3 or ipython interpreter through the command-line terminal.)

If you are new to python or just programming in general, or if you have no strong preference, we recommend that you use the Anaconda Spyder IDE, since it’s relatively easy to use and available on all platforms. VSCode is another recommended IDE.

If you are interested in what other IDEs are out there, have a look at the alternate IDEs page. Again, we strongly recommend you stick with the Anaconda Spyder IDE that we will be installing below; Lecturers and tutors will not in general be able to provide technical support for any problems you may face using or installing alternative IDEs

The IDE that is used in the lectures is Spyder or VS Code.

There will be information to help you navigate the Anaconda Spyder IDE and VSCode in Lab1. (Lab1 does not have any information for navigating other IDEs, consult the documentation of your specific IDE if you used an alternative IDE.)

We provide installation instructions for the Anaconda Spyder IDE or VS Code. Please refer to the installation guides of your IDE for other IDEs.

Installing Anaconda#

Installing Anaconda Spyder IDE is easy.

  1. Download the latest version of the distribution here. Make sure you select the python 3 version, not the python 2 one.
  2. Run the installer once it is done downloading and follow the prompts. Leave all options in their default state. Click Yes if you are asked to make Anaconda your default Python installation.
  3. Done! You should now be able to find the Spyder IDE in your start menu (in Windows it will be found under the Anaconda3 folder).

We also have a short video that shows the entire process of downloading and installing Anaconda Spyder from start to finish in detail available below.

anaconda install video fake thumbnail.

Testing your Anaconda installation#

  1. Run the anaconda navigator. Click here for instructions on how to do this.
  2. On the anaconda navigator, search for the JupyterLab application tile, and left-click on the Launch button right below the JupyterLab application tile.
  3. Then, on the right hand side pane, under the Notebook icon, click on the Python 3 (ipykernel) icon. This should open a new tab on your web browser.
  4. Inside the web browser tab, you will see a text cell (actually a code cell) where you can type Python code. Copy and paste the code below in that cell. Ensure after pasting that there are not trailing blank spaces in any of the lines of code.
    import matplotlib.pyplot as plot
    import numpy as np
    x = np.arange(0,4*np.pi,0.01)
    y = np.sin(x)
    plot.plot(x,y)
    plot.grid()
    plot.show()
    
  5. Then, execute the code cell by first left-clicking on the cell and then hitting the Shift-Enter shortcut on the keyboard (Shift-Enter stands for: While holding pressed the Shift keyboard key, press the keyboard key labelled as Enter)
  6. If everything went ok, the code cell should plot the graph of f(x)=sin(x) right below the code cell. If you don’t get the plot and/or you get error messages, then something went wrong, and you should come to the Python environment installation issues section so that you can get technical support from the tutors.

Extra Info: 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

bars search times arrow-up