Every notebook this term started with import numpy and it simply worked. That was not Python being helpful. That was Google having already installed it for you.
# in Colab — this just works import numpy as np
# on your laptop — this does not import numpy as np ModuleNotFoundError: No module named 'numpy'
The standard library gave you pathlib, csv, random. Everything else — numpy, pandas, matplotlib — someone else wrote, and you have to go and get.
One command builds a project with everything a data analysis needs. Then this week's notebooks, running in VS Code, on your own machine.
Colab pre-installs several hundred packages. Convenient — until you need to explain to someone else exactly what your analysis depends on.
numpy lives on PyPI, the Python Package Index. Getting it means downloading it — and the only real question is where to put it.
pypi.org 600,000 packages, free to download
│
│ uv downloads numpy, pandas, matplotlib …
▼
my-project/.venv/ a private copy of Python
+ exactly those packagespyproject.toml the list: "numpy, pandas, matplotlib" uv.lock the exact versions: numpy 2.5.4 … .venv/ the packages themselves
Your dissertation needs numpy 1.26, a new tool needs 2.5. Install both for the whole machine and one of them breaks — usually the one you are not looking at.
Each project folder gets its own .venv — a virtual environment. They cannot see each other, so they cannot break each other.
pyproject.toml + uv.lock let a collaborator — or you-in-two-years — rebuild exactly your environment with one command.
uv-start is a small tool that builds a ready-made data analysis project. Install it once, then use it for every project you start.
uv tool install gives uv-start its own environment and puts the command where every terminal finds it. Packages like numpy are different: they go in each project's .venv.uv tool list shows your tools · uv tool upgrade uv-start updates one.
Makes the folder, a pyproject.toml, a .venv with numpy, pandas, matplotlib and seaborn, and VS Code settings for notebooks. By hand that is a dozen commands.
Run step 3 from your home folder — wherever a fresh terminal opens. The project appears as a new folder called lab5-neurons. Only need it once? uvx uv-start@latest lab5-neurons --data runs it without installing.
lab5-neurons/ ├── pyproject.toml the list of packages ├── uv.lock their exact versions ├── .venv/ the packages themselves ├── data/ raw data — read it, never overwrite it ├── results/ figures and tables you make ├── sample.ipynb a notebook to test the setup ├── README.md how all of this works └── .vscode/ settings + recommended extensions
Raw data stays untouched in data/; anything your code makes goes to results/. Delete results/ and you can always make it again. Lose data/ and you cannot.
uv add scipy # need another package?
# → pyproject.toml, uv.lock and .venv
# all updated in one gouv add writes the package into pyproject.toml, so the next person's uv sync gets it too. pip install does not.
The same layout works for your final project — and for every analysis after it.
[1] dff = np.loadtxt(...)
[2] dff.mean()
0.058 ← answer under the cell
[3] plt.plot(dff)
[ the figure ] ← right here, tooCells you run one at a time, with the answer and the figure right underneath. Ideal for exploring data and telling the story of an analysis. This lab, and your final project.
# count_trials.py — runs top to bottom, every time
import numpy as np
go = np.loadtxt("data/neuron.csv", delimiter=",",
skiprows=1, usecols=2)
starts = np.where(go == 1)[0][::9]
print(len(starts), "go trials")Plain text, run top to bottom with uv run count_trials.py. Ideal for tools, pipelines and functions you reuse, test and share.
The notebook trap: cells run in any order, so a notebook can work today only because of a cell you ran yesterday. Before you trust a result: Restart → Run All. Curious? marimo, the new kid on the block, is a notebook saved as a .py file that reruns dependent cells for you, so it cannot get out of order.
A notebook's kernel is the Python that runs its cells. Pick .venv and you get this project's packages. Pick anything else and import numpy fails.
Mac: …/lab5-neurons/.venv/bin/python Windows: …\lab5-neurons\.venv\Scripts\python.exe
✅ Ends in .venv? Green sticky up. Anything else? Red sticky — see the last slide.
Open the folder, not a single file — that is how VS Code finds .venv by itself.
Same notebooks as Colab — now in your project. Run this in VS Code's terminal (Terminal → New Terminal), which already opens inside lab5-neurons.
⚠️ Terminal trouble? Download lab5.zip in the browser, unzip it, and drag the three notebooks and the data folder into VS Code's Explorer.
lab5-neurons/ ├── 01_numpy_small_data.ipynb everyone starts here ├── 02_neuron_analysis_basics.ipynb then this … ├── 02_neuron_analysis_advanced.ipynb … or this ├── data/ │ ├── neuron_0588_20180828_5_lecture.csv │ └── neuron_0406_20180620_8_lecture.csv ├── results/ └── sample.ipynb
Three new notebooks in the Explorer, two CSVs inside data/.
The notebooks read from data/ — and fetch the files themselves if they are missing, so they still work in Colab.
plt.savefig("results/go_vs_nogo.png", dpi=150)01 go 1.0 nogo 0.2 go ÷ nogo 5.0 02 basics go 0.29 nogo 0.057 go ÷ nogo 5.1 02 advanced neuron 1: 5.1 neuron 2: 1.2
Neuron 1 fires five times harder for go than for nogo — it carries the mouse's decision. Neuron 2 barely tells them apart. Same code, opposite biology.
Nothing here needs the internet any more. Close Colab — this is where your final project will live too.
uv / uv-start: command not found
Close the terminal and open a new one. uv-start still missing? Run uv tool update-shell, then a new terminal. uv missing? Re-run the installer from Lab 2.
code: command not found (Mac)
In VS Code: ⌘⇧P → Shell Command: Install 'code' command in PATH. Or skip it: File → Open Folder → lab5-neurons.
No .venv in the kernel list
Check you opened the folder. Then run uv sync in VS Code's terminal and ⌘⇧P / Ctrl+Shift+P → Developer: Reload Window.
ModuleNotFoundError: No module named 'numpy'
Wrong kernel. Top right of the notebook → Select Kernel → .venv. Never pip install.
PowerShell: parameter name 'O'
In PowerShell, curl means something else. Type curl.exe — with the .exe.
Running cells… asks to install ipykernel
You picked a Python other than .venv. Cancel, and select .venv — it already has ipykernel.
Still stuck after that? Red sticky up — this is exactly what the lab is for.