Python Installation

The installation instructions here are based on the MIALab setup, so you can reuse a similar workflow next semester as well: MIALab documentation

The installation instructions use uv to create a local virtual environment in .venv and install all dependencies.

Windows | Linux | macOS

Windows

The installation has been tested on Windows 10 and 11.

  1. Install git

    • Download git and install

  2. Clone CAS-Assignment repository

    • Open “Windows Terminal” (PowerShell)

    • cd /path/to/where/you/want/the/code

    • git clone https://github.com/persmed/cas-assignment.git

    • cd cas-assignment

  3. Install uv

  4. Sync the environment (from the repository root directory)

    • uv sync

  5. Activate the cas environment

    • Run .\.venv\Scripts\activate

    Note

    PowerShell Execution Policy blocks script execution by default on many Windows systems. In that case you may see an error such as:

    ❯ .\.venv\Scripts\activate
    .\.venv\Scripts\activate: File path\to\cas-assignment\.venv\Scripts\activate.ps1 cannot be
    loaded because running scripts is disabled on this system. For more information,
    see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.
    

    To allow running local scripts, execute:

    Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

  6. Execute the installation test script to verify the installation

    • Run python cas\test_installation.py

    Note

    The installation test requires the file data/planning/pelvis_ct.nii.gz. If it is missing, cas/test_installation.py will stop and print instructions on where to place the file.

    Download and copy the file by following Assignment Environment Setup.

Linux

The installation has been tested on Ubuntu 16.04 LTS (should also work on newer Ubuntu versions).

  1. git installation

    • sudo apt-get install git

  2. Clone cas-assignment repository

    • cd /path/to/where/you/want/the/code

    • git clone https://github.com/persmed/cas-assignment.git

    • cd cas-assignment

  3. Install uv

  4. Sync the environment (from the repository root directory)

    • uv sync

  5. Activate the cas environment

    • source .venv/bin/activate

  6. Execute the installation test script to verify the installation

    • python cas/test_installation.py

    Note

    The installation test requires the file data/planning/pelvis_ct.nii.gz. If it is missing, cas/test_installation.py will stop and print instructions on where to place the file.

    Download and copy the file by following Assignment Environment Setup.

macOS

The installation has been tested on macOS 10.13.6 (should also work on newer macOS versions).

  1. git installation

    • Download git and install

  2. Clone cas-assignment repository

    • cd /path/to/where/you/want/the/code

    • git clone https://github.com/persmed/cas-assignment.git

    • cd cas-assignment

  3. Install uv

  4. Sync the environment (from the repository root directory)

    • uv sync

  5. Activate the cas environment

    • source .venv/bin/activate

  6. Execute the installation test script to verify the installation

    • python cas/test_installation.py

    Note

    The installation test requires the file data/planning/pelvis_ct.nii.gz. If it is missing, cas/test_installation.py will stop and print instructions on where to place the file.

    Download and copy the file by following Assignment Environment Setup.


Conda Installation (Deprecated)

Deprecated since version 2026-03: The conda-based installation is deprecated. Use the uv-based installation above.

Windows | Linux | macOS

Windows

The installation has been tested on Windows 10 and 11.

  1. Install git

    • Download git and install

  2. Clone CAS-Assignment repository

    • Open “Windows Terminal” (PowerShell)

    • cd /path/to/where/you/want/the/code

    • git clone https://github.com/persmed/cas-assignment.git

    • cd cas-assignment

  3. Miniconda installation (official website)

    • Launch the Miniconda installer

    • Select an install for “Just Me” unless you’re installing for all users (which requires Windows administrator privileges)

    • Choose whether to add Miniconda to your PATH environment variable. We recommend not adding it to PATH, since this can interfere with other software.

    • Choose whether to register Miniconda as your default Python. Unless you plan on installing and running multiple Python distributions, you should accept the default and leave this box checked.

  4. Verify the installation

    • Open “Miniconda Prompt”

    • conda list, which should list installed conda packages

  5. Create a new Python environment with all dependencies

    • conda env create --file environment.yml

  6. (Optional) If you are using PowerShell instead of the command prompt run

    • conda init powershell

  7. Activate the environment by

    • conda activate cas

    Note

    If conda activate does not work, run conda init once, then close and reopen the terminal.

  8. Execute the installation test script to verify the installation

    • python cas/test_installation.py

    Note

    The installation test requires the file data/planning/pelvis_ct.nii.gz. If it is missing, cas/test_installation.py will stop and print instructions on where to place the file.

    Download and copy the file by following Assignment Environment Setup.

Linux

The installation has been tested on Ubuntu 16.04 LTS (should also work on newer Ubuntu versions).

  1. git installation

    • sudo apt-get install git

  2. Clone cas-assignment repository

    • cd /path/to/where/you/want/the/code

    • git clone https://github.com/persmed/cas-assignment.git

    • cd cas-assignment

  3. Run Miniconda installation script (official website)

    • Download the Miniconda installer for your architecture, then run for example: bash <path_to_file>/Miniconda3-latest-Linux-x86_64.sh

      • Scroll to the bottom of the license and enter yes to agree the license

      • Accept suggested installation path (or change it if you know what you do)

      • yes to initialize Miniconda (adds conda to your shell)

      • Reopen the terminal

  4. Verify the installation

    • conda list, which should list installed conda packages

  5. Create a new Python environment with all dependencies

    • conda env create --file environment.yml

  6. Activate the environment

    • conda activate cas

    Note

    If conda activate does not work, run conda init once, then close and reopen the terminal.

  7. Execute the installation test script to verify the installation

    • python cas/test_installation.py

    Note

    The installation test requires the file data/planning/pelvis_ct.nii.gz. If it is missing, cas/test_installation.py will stop and print instructions on where to place the file.

    Download and copy the file by following Assignment Environment Setup.

macOS

The installation has been tested on macOS 10.13.6 (should also work on newer macOS versions).

  1. git installation

    • Download git and install

  2. Clone cas-assignment repository

    • cd /path/to/where/you/want/the/code

    • git clone https://github.com/persmed/cas-assignment.git

    • cd cas-assignment

  3. Miniconda installation (official website)

    • Download and run the Miniconda installer for macOS (Intel or Apple Silicon, depending on your machine)

    • Follow the installer steps

    • Reopen the terminal

  4. Verify the installation

    • conda list, which should list installed conda packages

  5. Create a new Python environment with all dependencies

    • conda env create --file environment.yml

  6. Activate the environment

    • conda activate cas

    Note

    If conda activate does not work, run conda init once, then close and reopen the terminal.

  7. Execute the installation test script to verify the installation

    • python cas/test_installation.py

    Note

    The installation test requires the file data/planning/pelvis_ct.nii.gz. If it is missing, cas/test_installation.py will stop and print instructions on where to place the file.

    Download and copy the file by following Assignment Environment Setup.