Topic outline

  • Instructions to get Python

    On this course, we will use Python and some common packages for scientific computing. This page contains separate guides for two alternative approaches:

    1. Setting up the Python environment for the course using Anaconda
    2. Setting up the Python environment for the course using virtualenv (Aalto Linux)

    Anaconda is a distribution of Python that works on all the most common operating systems (Linux, Windows, MacOS) and makes installing the required packages easy. On Aalto managed Linux computers the approach using Anaconda will not work, and the guide for virtualenv should be followed instead! We recommend following the instructions on this page to get a version of Python that’s been tested to work with the lecture materials and exercises. We cannot guarantee that your own custom installation of Python works. If you have trouble getting Python to work, come to the exercise session for help, or email one of the assistants.

    Setting up the Python environment for the course using Anaconda

    Step 1. Installing Anaconda (Linux)
    On a Linux computer follow these steps to install Anaconda:

    1. Download the latest version of Miniconda at https://docs.conda.io/en/latest/miniconda.html. This is essentially the same software as Anaconda but it takes less space and is faster to install.

    2. Open terminal and go to the folder where the file was downloaded

    3. Run

          bash Miniconda3-latest-Linux-x86_64.sh 

    and follow the instructions.

    Step 1. Installing Anaconda (Windows, MacOs)
    If you’re using Windows or MacOS, download the latest miniconda version for your operating system and install the software using the graphical installer.

    Now you should have a working installation of conda on your system. Next we will create a dedicated Python environment for this course.

    Step 2. Download the environment file here

    Step 3. Go to the download folder and create the environment with

    conda env create -f  environment.yml

    More information available at https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-from-an-environment-yml-file

    Step 4. Activate the environment with

    conda activate cp

    and you should see “(cp)” at the start of a line in your terminal which means you have a working python environment tailored for this course. Here, ‘cp’ is the name of the environment, short for computational physics. When you open a new terminal window and wish to use this environment you have to run

    conda activate cp 


    Setting up the Python environment for the course using virtualenv (Aalto Linux)

    If you are using an Aalto managed Linux computer, such as in the exercise room, the approach using Anaconda will not work. This guide goes through setting up the Python environment using virtualenv. You can also access an Aalto Linux computer remotely at vdi.aalto.fi. There you should choose the Ubuntu 20.04 virtual machine.

    Step 1. Install virtualenv by running

    python3 -m pip install virtualenv

    Step 2. Create a virtual Python environment by running

    python3 -m virtualenv cp

    Step 3. Activate the virtual environment that was created by running

    source cp/bin/activate

    Step 4. Install the required Python packages to the virtual environment using pip:

    python -m pip install numpy matplotlib scipy librosa scikit-learn jupyter

    Step 5. Now you can open Jupyter notebook files by running

    jupyter-notebook

    in the folder where the notebook file is located. If the virtual environment that you created has been activated, jupyter-notebook should automatically use the virtual environment's Python interpreter for running the code in the notebook. When you open a new terminal window and wish to use this environment you have to run

    source cp/bin/activate

    before opening a Jupyter notebook.