Installing the DMOR Course Environment

This guide explains how to install the Python environment required to run the optimization examples used in the course.

The installation only needs to be done once on your computer.


1. Install Python

You must install Python 3.11.

Check whether Python 3.11 is already installed:

python3.11 --version

If the output is something like

Python 3.11.x

you are ready to continue.

If Python 3.11 is not installed, install it using the instructions below.


Windows

  1. Download Python 3.11 from
    https://www.python.org/downloads/

  2. Run the installer.

  3. Important: during installation check:

Add Python to PATH
  1. After installation, open a new terminal and verify:
python3.11 --version

macOS

If you use Homebrew:

brew install python@3.11

Then verify:

python3.11 --version

Linux (Ubuntu / Mint)

Install Python 3.11:

sudo apt update
sudo apt install python3.11 python3.11-venv

Then verify:

python3.11 --version

2. Create a Working Folder

Create a folder for the course and move into it:

mkdir dmor-course
cd dmor-course

Download the file requirements.txt from eClass and place it inside this folder.


3. Create a Virtual Environment

Create a private Python environment for the course:

python3.11 -m venv .venv

4. Activate the Environment

macOS / Linux

source .venv/bin/activate

Windows

.venv\Scripts\activate

After activation your terminal prompt should start with:

(.venv)

5. Upgrade pip

Before installing the packages, upgrade pip:

python -m pip install --upgrade pip

6. Install the Course Packages

Install all required packages using:

pip install -r requirements.txt

This will install:


7. Test the Installation

Start Python:

python

Then run:

from dmor.model import Model

If no error appears, the installation was successful.

Exit Python with:

exit()

8. Running the Examples

Download the example files from eClass.

Run an example with:

python example_file.py

Make sure the virtual environment is activated before running examples.


9. Each Time You Work on the Course

Open a terminal in the course folder and activate the environment.

macOS / Linux

source .venv/bin/activate

Windows

.venv\Scripts\activate

Then run your Python scripts or notebooks.


Troubleshooting

Wrong Python Version

Check your Python version:

python --version

It must be Python 3.11.

If not, recreate the environment using:

python3.11 -m venv .venv

pip Not Found

Use:

python -m pip install -r requirements.txt

instead of pip.


Installation is Slow

Make sure pip is updated:

python -m pip install --upgrade pip

Summary

Installation consists of four commands:

python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt

After this, the environment is ready for all course examples.