This class uses Python for the coding exercises and the project. Below you will find instructions for installing a working Python environment and all the libraries that we will use throughout the semester.
Warning
This course previously used Matlab, and transitioning to Python has not been an easy task. Hiccups are to be expected along the way, so do not hesitate to ask questions during exercise sessions or on the forum about any issues or bugs you may find. We will make updates to correct them throughout the semester, and will inform all of you when we do (e.g. to update the libraries).
All the exercises and the setup instructions can be found in this repo (https://github.com/PREDICT-EPFL/MPC-Course-EPFL). We will update it regularly to add exercises and fix issues.
The setup will use conda to install Python and create a dedicated environment for the course, and pip to install the required packages. Everything has been tested on macOS, Linux and Windows (not WSL though).
-
Install git: Make sure you sure you have
gitinstalled on your computer. If you don't, please follow the following instructions: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git -
Clone the repo: Open a terminal and clone the repo (any terminal will do on macOS/Linux, open Git Bash on Windows) at your desired location on your computer.
git clone https://github.com/PREDICT-EPFL/MPC-Course-EPFL.git- Install conda: Install a
condadistribution. The simplest for beginners is Anaconda, but any other will do (miniconda, miniforge, etc.). Note that you do not have to create any account to download Anaconda, just skip all registration steps. Once the installation is complete, you should be able to run the following in a new terminal on macOS/Linux or Anaconda Prompt/PowerShell Prompt on Windows:
conda info- Create environment: In the same terminal as before, navigate inside the cloned the repo and create the conda environment with the following commands:
conda create -y -n mpc2025 python=3.12 pip
conda activate mpc2025
pip install -r locked-requirements.txt- Install editor: For beginners, we recommend using Jupyter Lab to edit the notebooks for the programming exercises. It should already be installed with the previous steps, so you can start it by running in the same terminal as before with
jupyter labIf you prefer using another editor like VSCode or PyCharm, please do! Simply make sure you have installed all the appropriate extensions and make sure that these will not install dependencies in the environment we created (in particular, do not accept notifications offering to install jupyter or ipykernel or pandas and call for help to avoid messing up your environment).
For VSCode, please install the Python and Jupyter extensions, and follow these instructions to associate an environment to the MPC-Course-EPFL folder.
Make sure to:
- always open
MPC-Course-EPFLas a folder and not a workspace - choose the
mpc2025conda enviroment we have just created - if it's not done automatically, use the kernel associated to the
mpc2025environment in every notebook
The best way to test if your installation worked, is to open the first tutorial notebook tutorial.ipynb that will go through some documentation you might want to read to get up to speed with libraries we will use this semester.
- Make a copy of the
tutorial.ipynbnotebook and rename it tomy_tutorial.ipynb. - Open Jupyter Lab or VSCode as you did above.
- Open the
my_tutorial.ipynbnotebook and select the kernel in thempc2025environment if it's not done automatically.
If we ever update the libraries versions and ask you to update your environment:
- Open a regular terminal on macOS/Linux or Git Bash on Windows, navigate to this repository and run
git pull- Now open a new terminal on macOS/Linux or Anaconda Prompt/PowerShell Prompt on Windows, activate the environment again and simply reinstall the dependencies:
conda activate mpc2025
pip install -r locked-requirements.txt