VS Codium, Python, Ollama, Qwen, and an agent in your terminal
HEC Montréal
qmib.load(...), and know where the file actually is| The choice | The reason |
|---|---|
| VS Codium over VS Code | The same editor with the telemetry removed. You will work on licensed and confidential data; the tooling should not phone home about it. |
| A local Python over a hosted notebook | Your environment is a file you can rebuild and a version you can name. A cloud kernel is a state you cannot reproduce. |
| Plain files and git over a notebook platform | Reproducibility is graded here. A commit history is auditable; an execution order is not. |
Tooling is a governance decision, and you should be able to defend yours. That is the first substantive lesson of the course.
Six pieces, in this order. Each one checks before you move on.
| 1 | VS Codium | the editor — Visual Studio Code without the telemetry |
| 2 | Extensions | Python support, from the Open VSX registry |
| 3 | The course materials | this repository, on your Desktop |
| 4 | Python | and a project environment, .venv |
| 5 | Ollama + Qwen 2.5 Coder | a language model that runs on your machine |
| 6 | aider | the agent you talk to in the terminal |
Session 1 does not include installation time. Arriving without a working environment means you cannot take part in either half.
Nothing exotic. No graphics card is required — everything here runs on the processor, more slowly.
| Enough | Comfortable | |
|---|---|---|
| RAM | 8 GB | 16 GB |
| Free disk | 12 GB | 20 GB |
| CPU | anything from the last five years | Apple Silicon, or Intel i7 10th gen and later |
| Graphics | none needed | 8 GB VRAM makes the model 5–10× faster |
On 8 GB, use the 3b model. On 16 GB with no graphics card, still use the 3b — system memory is not what makes it fast.
Speed is measured in tokens per second, and roughly a token is a short word.
| Your machine | Tokens/second | A short answer takes |
|---|---|---|
| Dedicated GPU | 15–40+ | a second or two |
| Apple Silicon | 15–30 | a second or two |
| CPU only, 3b model | 8–20 | a few seconds |
| CPU only, 7b model | 3–8 | half a minute or more |
This is the whole reason the course uses the 3b. On a CPU the 7b is not a better model — it is the same answer, four times slower, and you will stop asking.
Always the VS Codium terminal. Not the macOS Terminal, not PowerShell.
Open it with Terminal → New Terminal, or Ctrl + `.
Why it matters: the VS Codium terminal starts inside your project folder and sees your .venv. The system terminal does neither, which is the single most common reason a command that “should work” does not.
A terminal reads your PATH once, when it opens. VS Codium reads it once, when it launches. Install something and the window you already have open will not see it — the command stays “not found” and it looks like the install failed.
| After installing | Do this |
|---|---|
| A VS Codium extension | Developer: Reload Window — Cmd/Ctrl + Shift + P |
| Python or git | Quit VS Codium entirely and reopen it |
| Ollama or aider | A new terminal is enough — + in the terminal panel |
On Windows this bites hardest, because the installers change PATH and nothing already running picks it up — not even a new terminal tab, because the tab inherits PATH from VS Codium itself. Quit the editor and reopen it.
The symptom is always the same sentence: «… n’est pas reconnu comme nom d’applet de commande», or “is not recognized as a cmdlet”. It means the file exists and your shell cannot see it — never that the install failed.
Download from vscodium.com and install it as you would any application. You will live in two panels: the editor on the right, the terminal below it.
Then add four extensions. VS Codium uses the Open VSX registry, not Microsoft’s Marketplace — View → Extensions, or Cmd/Ctrl + Shift + X.
Reload the window afterwards — Cmd/Ctrl + Shift + P → Developer: Reload Window. An extension that has just been installed is not active until you do.
Download the repository as a ZIP, unzip it directly on your Desktop, and keep the folder name:
Then File → Open Folder and choose it.
Every command in this course assumes you are in that folder. If your paths differ, nothing else on these slides will work.
In Session 02 you will do this properly, with git and your own group branch.
3.12.10 specifically. Not “the latest”, not whatever the download page offers first. python.org/downloads/release/python-31210
sudo apt install python3.12 python3.12-venvWhy .10 and not a later 3.12: the branch is in security-only maintenance, and those releases ship as source code only. 3.12.10 is the last one with a ready-made installer, which is the one you want.
Then quit VS Codium and reopen it, before the next slide. The installer changes PATH and a window already open will not see it.
If it does not work:
aider-chat declares requires-python <3.13. On 3.13 or 3.14 it cannot be installed at all.
From the repository root, two commands. Name the version on the first — a bare python3 or py picks the newest you have installed.
Then activate it. Every new terminal, not only this one:
Your prompt must now begin with (.venv). If it does not, the activation did not take, and nothing you install afterwards will be visible to the course.
pip install typed without these puts the packages somewhere the course cannot see. The symptom arrives a week later, as ModuleNotFoundError, and looks like a broken laptop rather than a missed step.
Desktop/quantitative-methods — ls on macOS and Linux, dir on Windows, should list requirements.txt(.venv)Inside an activated environment, plain python and pip are the right commands on all three platforms. Naming the version was only needed to create it.
If it does not work: python --version is not 3.12
Now, and only now:
It reads requirements.txt from the folder you are standing in and installs every line of it into .venv — pandas, statsmodels, scikit-learn and the rest. A few minutes, and a lot of output. Warnings are normal; only ERROR is not.
You will read more code this term than you write — the course’s own scripts, the authors’ replication packages, your group’s work. A model beside the file answers “what does this do” without your leaving the file.
| The choice | The reason |
|---|---|
| Local, not hosted | The data never leave the machine. No API key, no subscription, no terms of service to read before you paste a client’s numbers into it. |
| A small model | It runs on a laptop. Knowing what is achievable without a frontier system is the realistic institutional constraint, and most of your career will be spent inside it. |
| In the editor | Selection plus a keystroke. A model you have to copy into a browser is a model you stop using by week four. |
It is a sparring partner, not an oracle — the slides at the end of this deck say what that means in practice, and it is graded.
| Continue | Ollama | |
|---|---|---|
| RAM | negligible itself — the model is the cost | 8 GB for a 3b, 16 GB for a 7b |
| Disk | ~50 MB | 2 GB per model, plus 274 MB for the embedder |
| Graphics | none | none, but 8 GB VRAM is 5–10× faster |
| Network | none after setup | none after the models are pulled |
Rule of thumb for any model: it needs its file size plus about a fifth in memory. The 3b is 1.9 GB on disk and around 3.4 GB loaded.
Continue does not manage the context window for you — which is why 2.5 asks you to check it. Set it too small and the model answers about the part of your file it can still see, without saying so.
Install ollama.com, then in the VS Codium terminal:
The second model is used in Session 09 for text embeddings. Pull it now while you have bandwidth.
Check it answers:
ollama: command not found right after installing? Open a new terminal. On Windows, quit VS Codium and reopen it.
Turn your wifi off and run that again. It should still answer. That is the point of running it locally.
Start with the 3b. It is the one that works on a laptop without a dedicated graphics card, which is most laptops.
Only try a bigger one once you have seen ollama ps report 100% GPU on the 3b. If it already says 100% CPU, a 7b will be three times slower at the same task, not three times better.
Whichever you pull, put that exact name in config.yaml and in your aider command. A name that is not there produces a confusing error rather than a missing-model one.
Installed, Continue still talks to nothing. It needs a config file, and the easiest way to open it is from inside Continue itself:
Open the Continue panel → the gear icon at its top right → Configure. It opens config.yaml in the editor, creating it if it does not exist.
If you would rather do it from the terminal — the file lives in your home directory, and the path differs:
New-Item -ItemType Directory -Force "$HOME\.continue" | Out-Null
notepad "$HOME\.continue\config.yaml" # Windows$HOME\.continue on Windows is normally C:\Users\you\.continue. The folder starts with a dot, so File Explorer hides it unless Hidden items is ticked in the View ribbon.
name: qmib
version: 0.0.1
models:
- name: Local coder
provider: ollama
model: qwen2.5-coder:3b # the size you actually pulled
roles: [chat, edit, apply]
- name: Local embedder
provider: ollama
model: nomic-embed-text
roles: [embed]
context:
- provider: file
- provider: code
- provider: diff
- provider: terminalOpen a .py file, select a few lines, press Cmd/Ctrl + L. If the panel answers, you are done.
Nothing at all means no model server is listening. Start Ollama — the app on macOS and Windows, sudo systemctl start ollama on Linux.
aider sends your file to the model. If the context is small the model silently drops the beginning of it and answers about the part it still has — which looks like stupidity rather than truncation.
Load the model, then ask the server what it gave it:
8192 or more — do nothing. 2048 or 4096 — raise it, next slide.
This differs by platform, so check rather than assume. The macOS app asks for a very large window and the model caps it at its own maximum — 32768 for qwen2.5-coder:7b. On Windows the default is 4096, which aider will outgrow on any real file.
If it does not work:
Continue answers about code. aider changes it — it edits files, runs in your repository, and commits what it did.
| The choice | The reason |
|---|---|
| A terminal agent | You see every command it proposes before it runs. A model that edits your files silently is a model you cannot be accountable for. |
| Its own environment | aider pins package versions the course also uses. Installed beside the course rather than inside it, neither can break the other. |
| Commits attributed to you | The git log is one of the four records used to check that all three group members did the work. Whatever the agent writes is signed with your name — which is the point, and the responsibility. |
Two tools, two jobs: Continue to understand, aider to change. They talk to the same model.
| RAM | 8 GB with the 3b; 16 GB is where the 7b becomes reasonable |
| Graphics | not required |
| Python | its own, via pipx — never the course environment |
| A git repository | it edits files and commits; it expects to be inside one |
On a CPU-only laptop, treat aider as a reader and an adviser rather than an editor. It will answer questions about your code perfectly well. Asking a 3b to apply a multi-file edit is where it struggles — small models frequently fail to produce aider’s edit format, and you get “the LLM did not conform to the edit format” rather than a change.
Ollama’s default context is small, and it silently discards anything beyond it — aider’s own documentation calls this “especially dangerous because many users don’t even realize that most of their data is being discarded”.
aider handles it: it sets the context window per request, large enough for what it is sending plus 8k for the reply. So the ollama ps value you checked in part 2 matters for Continue, which does not do this — not for aider.
Which is why part 2 asked you to check it and part 3 does not.
One thing to do: look at your prompt.
| It shows | Do this |
|---|---|
(.venv) PS C:\...> |
type deactivate |
PS C:\...> |
nothing — you are already out |
That is the whole of it. The next three slides install aider, and they install it beside the course rather than inside it.
Why: aider pins its own versions of packages the course also uses. Installed into .venv it forces pip to satisfy both at once, which is where the resolver errors come from — and where a silent downgrade of something the course needs comes from. Kept separate, neither can disturb the other.
Name the version on both lines. Installing with one interpreter and calling with another is the whole of the no module named pipx problem.
ensurepath edits PATH, and nothing already running sees it. Quit VS Codium and reopen it before the next slide.
If it does not work:
Written as a module deliberately: pipx install aider-chat is the same thing and works too, but only once PATH has caught up. The module form does not care.
In a new terminal, aider --version should answer. If it does not, the command is still at ~/.local/bin/aider — %USERPROFILE%\.local\bin\aider.exe on Windows — and calling it there works regardless.
Point it at the server. The variable goes in aider’s terminal:
Then, on both:
ollama_chat/, not ollama/ — the second uses the completion endpoint and gives markedly worse answers. And use the tag you actually pulled: :3b, :7b or :14b.
If it does not work:
aider asks this the first time you run it in a repository. Say yes — though the repository already has the line, so you should not be asked at all. If you are, you are running in a folder that is not your clone.
It writes three things beside your work: the chat transcript, your input history, and a cache of the code it has read.
None of it belongs in a commit. The transcript is also a record of everything you asked — yours to keep, not to push.
Start it on one file, not the whole repository:
“What does load do when the file is already cached?”
Read what it proposes before you accept it. aider commits after each change it applies, and those commits are attributed to you.
--map-tokens 0 skips the repository map. Without it aider parses all 210 code files here before answering anything, which on a first run looks like a hang. Drop the flag once you are working on real code and want it to see the project.
A local model is slower than the hosted ones you are used to. How much slower depends on one thing, and ollama ps reports it:
| PROCESSOR | What to expect |
|---|---|
| 100% GPU | a few seconds for a sentence |
| CPU/GPU split | tens of seconds |
| 100% CPU | minutes — you are on the smallest model already; expect to wait |
100% CPU is normal on a laptop without a dedicated graphics card, and the 3b is still usable there — a sentence in tens of seconds rather than seconds. What it is not is a reason to try a bigger model.
Genuinely hung, rather than slow, looks different: no spinner, no partial text, and nothing in ollama ps at all. That means the server is not running.
aider, where you talk to the modelpython, where you check what it told youPlus the server — but on macOS that is the app in your menu bar, and on Windows and Linux it is a terminal you start once and leave alone.
The checking terminal is not optional. Every deliverable in this course requires you to document one thing the model got wrong — and you cannot do that without checking.
Activate the environment first. Your prompt must show (.venv) — this script checks what its own interpreter can see, so run outside the environment it reports every package as missing.
Check 0 is the environment itself. If it fails, nothing below it means anything — activate and run it again. Bring the output to class.
One check is allowed to warn rather than pass: the optional packages. Everything else must be [ok]. If something fails, the script prints what to do — and if you are still stuck, ask Qwen, which is itself a test of whether the setup works.
The local model is a sparring partner, not an oracle.
Ask it to argue against you. Its most useful output is the objection you had not considered — not the answer you were hoping for.
Verify every factual claim. It states plausible falsehoods with complete confidence, and does so most often about library APIs, statistical results and citations — which is exactly the material of this course.
Record what you checked. Every practice deliverable requires one documented instance where you caught the model being wrong or unable to support a claim. That is graded.
You are never penalised for using the model. You are penalised for using it uncritically.
reading-europe-2031.mdOptional, and worth it: the-supervised-learning-problem.md gives you the vocabulary Session 02 uses. Not required, not examinable.
| Repository on the Desktop | ☐ |
.venv built by 3.12 and activating |
☐ |
requirements.txt installed |
☐ |
| Qwen answers with the wifi off | ☐ |
verify_environment.py passes with (.venv) showing |
☐ |
| Europe 2031 read and annotated | ☐ |
| The Gates Notes piece read | ☐ |
| One question ready | ☐ |
Full checklist and troubleshooting: setup-vscodium-local-llm.md
Each of these is a real message someone saw, in the words they saw it. They are collected here rather than beside the steps so that a setup that goes smoothly reads as eight slides, not twenty.
deactivate is not recognisedaider is not recognisedpy --list marks the default — what a bare py uses. After installing 3.12 the star normally stays where it was:
That is expected, and it is why every command writes -3.12. Leave the star alone.
Activation is a PowerShell script, and Windows refuses to run scripts by default:
… ne peut pas être chargé car l'exécution de scripts est désactivée
sur ce système
… cannot be loaded because running scripts is disabled on this systemNothing is broken. Allow scripts for your own account — no administrator rights needed, and it is asked once, ever:
Answer O (or Y), then activate again.
RemoteSigned runs scripts you wrote or created locally, and still refuses unsigned scripts downloaded from the internet. It is the setting Microsoft recommends for development machines — not Unrestricted, and not Bypass.
Would rather change nothing? .venv\Scripts\activate.bat does the same job and is not a PowerShell script — but you must run it from cmd, not PowerShell, and you will need it in every new terminal.
Work through it in this order:
Does .venv exist? ls .venv\Scripts should list activate, activate.bat and Activate.ps1. If not, the venv command failed — read its output rather than moving on.
Is it the execution policy? «l’exécution de scripts est désactivée» — see the slide above. This is the usual answer.
Spelling. activate, not activiate. Tab-completion after .venv\Scripts\a will finish it for you and never misspells it.
Prefer the star on 3.12? setx PY_PYTHON 3.12, then a new terminal. Not needed for anything in this course, which always names the version.
A .venv remembers the interpreter that created it. Installing 3.12 afterwards changes nothing, and neither does PATH — the folder has to go and be rebuilt.
Windows. Quit VS Codium first — it holds the interpreter it has selected, and that alone can stop the folder being deleted. Then open PowerShell from the Start menu, not a terminal inside the editor:
Now reopen VS Codium, and in its terminal:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
.venv\Scripts\activate
python --version # must say 3.12.x
pip install -r requirements.txtStill le répertoire n'est pas vide? cmd /c "rmdir /s /q .venv" deletes it where Remove-Item will not.
deactivate is not a commandIt is a function that activation creates, so it exists only while an environment is active.
«Le terme deactivate n’est pas reconnu» is not a problem to solve — it is the answer to “am I in a virtual environment?”, and the answer is no. Skip the step and carry on.
The reliable indicator is the prompt: (.venv) at the start means active, nothing means not. On Windows the folder is then held by VS Codium rather than by your shell, which is why quitting the editor is the step that works.
macOS and Linux
rm -rf .venv
python3.12 -m venv .venv
source .venv/bin/activate
python --version # must say 3.12.x
pip install -r requirements.txtIf python --version says anything but 3.12, the venv line used the wrong interpreter — check you wrote -3.12 — and you need to delete and rebuild again.
If py or python prints Python introuvable / Python was not found and offers you the Microsoft Store, do not accept. There are two causes and the first is the common one.
1 · The Store alias is shadowing Python. Windows ships a stub named python.exe that does nothing but open the Store.
Start → search Manage app execution aliases → turn off both python.exe and python3.exe. Close the terminal and open a new one.
2 · Python is not installed, or not on PATH. Install from python.org/downloads — not the Store — and on the first screen tick Add python.exe to PATH before clicking Install. That checkbox is off by default and is the single most common setup failure.
Open a new terminal — PATH changes do not reach a terminal that is already running.
A version number and a path under Program Files or AppData means you are fine. A path ending in WindowsApps means the Store alias is still in the way: go back and turn it off.
py is the right command on Windows even once PATH is set — it finds every installed version and picks the newest. Inside an activated .venv, plain python works and refers to the environment’s own interpreter.
ollama ps showed 2048 or 4096 — the usual case on Windows.
Change it in the Ollama app, not with an environment variable. The desktop app stores its own context length and passes it to the server every time it starts, so it overrides setx and launchctl — which is why setting those appears to do nothing at all.
Open Ollama → its Settings → Context length. Set 8192 or more, then quit Ollama completely and start it again.
On Windows, quit from the system tray — closing the window leaves the server running, and a server that never stopped never re-reads the setting.
The setting is read when the server starts and the window is sized when the model loads, so both have to happen again:
CONTEXT should now read 8192. If it still says 4096, Ollama did not fully restart.
There the server is a systemd service and the environment variable is the only control:
Bigger is not free: the context is held in memory beside the model, so a very large window on a small machine costs speed. 8192 is enough for aider to hold a file and its own instructions.
pipx is a convenience. A plain environment does the same job with nothing on PATH to go wrong:
py -3.12 -m venv $HOME\aider-env
& "$HOME\aider-env\Scripts\pip" install aider-chat
& "$HOME\aider-env\Scripts\aider" --versionpython3.12 -m venv ~/aider-env
~/aider-env/bin/pip install aider-chat
~/aider-env/bin/aider --versionThat is all pipx does. Run aider by its full path from then on, and it stays completely separate from the course environment — which was the only point.
aider n'est pas reconnu?pipx installed it; your shell just cannot see it yet. Confirm it is there, and where:
pipx puts the command in ~/.local/bin — %USERPROFILE%\.local\bin on Windows. Call it by its full path and it runs whatever PATH says:
To fix it properly rather than working around it: py -m pipx ensurepath (python3 elsewhere), then quit VS Codium entirely and reopen it. A new terminal tab is not enough on Windows — the editor itself is holding the old PATH.
| What you see | Why | Fix |
|---|---|---|
Python introuvable (Windows) |
Store alias shadowing Python | Turn off the app execution aliases — earlier in this appendix |
ModuleNotFoundError in VS Codium |
Wrong interpreter selected | Cmd/Ctrl + Shift + P → Python: Select Interpreter → .venv |
pip fails |
Environment not active | Check your prompt starts with (.venv) |
| l’exécution de scripts est désactivée (Windows) | PowerShell blocks scripts by default, and activation is one | Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned, then activate again |
le répertoire n’est pas vide deleting .venv |
Something holds a file inside it — usually VS Codium’s selected interpreter | Quit VS Codium, delete from a plain PowerShell. Last resort cmd /c "rmdir /s /q .venv" |
deactivate n’est pas reconnu |
It only exists while an environment is active | Nothing to fix — you are not in one. Skip the step |
| Slow on Apple Silicon | Rosetta build of Python | Install the arm64 build |
| What you see | Why | Fix |
|---|---|---|
pipx n’est pas reconnu |
pip install --user put the script in a folder Windows does not have on PATH |
Run it as a module: py -3.12 -m pipx … |
No module named pipx |
It was installed for one interpreter and called from another — or --user was refused because .venv was active |
Deactivate, then py -3.12 on both lines |
aider: command not found |
pipx’s folder is new on PATH | New terminal; on Windows restart VS Codium. Or py -m pipx run aider-chat |
| Resolver errors installing aider | It was installed into .venv |
Use pipx, which keeps it separate — part 3 |
| aider sits there after your first question | It is parsing 210 files to build a repo map | Start it with --map-tokens 0 and name one file |
| aider forgets your file | The context window is too small | ollama ps to read it; raise it in the Ollama app’s settings, not with an environment variable |
connection refused from aider |
Nothing on 11434 | Start Ollama: the app on macOS and Windows, systemctl start ollama on Linux |
| What you see | Why | Fix |
|---|---|---|
ollama: command not found |
Not on PATH yet | New terminal; on Windows restart VS Codium |
| Continue answers nothing | No server on 11434 | Start Ollama: the app on macOS and Windows, systemctl start ollama on Linux |
| The model is very slow | ollama ps says 100% CPU — it does not fit in graphics memory |
Pull qwen2.5-coder:3b, change it in config.yaml and the aider command |
address already in use / une seule utilisation … socket |
Ollama is already running — it always is | You do not need ollama serve. Set the variable, restart Ollama |
| An extension does nothing | Installed but not loaded | Developer: Reload Window |
Maths shows as raw $...$ |
No preview extension | Install Markdown Preview Enhanced, open with Cmd/Ctrl + K V |
MATH60033A · Session 01 pre-session · Thierry Warin, PhD · HEC Montréal