import sys
print(sys.version)3.12.16 (main, Oct 28 2026, 02:01:20) [GCC 14.2.0]
20 min of teaching10 min of exercisesbeginner
environment.yml (conda/mamba) or requirements.txt (uv or pip + venv) and open it in JupyterLab or VS Code.scripts/check_env.py and read its output.Every episode from Chapter 1 onwards asks you to run code, and every lab is a Jupyter notebookJupyter notebookA document mixing code cells, their outputs and text; the format of the labs.. You therefore need one working Python with six libraries (NumPy, pandas, matplotlib, seaborn, scikit-learn and joblib) before anything else. There are two ways to get it. Option A takes two minutes and nothing is installed. Option B takes twenty minutes and gives you a setup you will keep for years. Pick one now; you can add the other later, and the rest of the course does not care which you chose.
Which option?
Choose Colab if you are on a locked-down or shared machine, if you have never installed developer software, or if you want to start Chapter 1 in the next five minutes. Choose a local install if you will work offline, if your data must not leave your computer, or if you already use Python. If in doubt, start with Colab and come back here when it starts to feel limiting.
Google ColabGoogle ColabA free, browser-based Jupyter environment from Google; nothing to install. is a free service that runs Jupyter notebooks on Google’s computers and shows them in your browser. You need a Google account and nothing else. Every lab page in this course has an Open in Colab button that loads the lab notebook directly; for the episodes, open a blank notebook at colab.research.google.com and type or paste the cells as you read.
Three things to know before you rely on it:
requirements.txt so that the rendered pages are reproducible, but every cell in Part I has been written to run on a current Colab as well. If a cell ever behaves differently, the check below will tell you which library is involved.To check what a Colab session has, open scripts/check_env.py on GitHub (Edit this page in any footer takes you to the repository), copy the whole file into a cell and run it. It prints one line per library, which you will learn to read in the check section below.
‘Runtime disconnected’
When Colab idles, the runtime disconnects and all variables are gone, though the notebook text is intact. Reconnect (the button at the top right) and run the cells again from the top: Runtime → Run all. This is not a bug in your code.
A local install has one rule that explains everything else: one project, one environment. A virtual environmentvirtual environmentAn isolated set of installed packages for one project, so versions don’t clash between projects. is a self-contained folder with its own Python and its own installed packages. The course lives in one; your next project lives in another; nothing you install for one can break the other, and the Python that came with your operating system is never touched. Both routes below create such an environment; they differ only in which tool manages it.
conda / mambaconda / mambaPackage managers that create isolated environments and install scientific libraries. installs packages from the conda-forge channel, which carries compiled scientific software that pip cannot always provide. Parts II–IV add RDKit, Open Babel and PyTorch, all easiest to install this way, so if you plan to go past Part I this is the route to take. mamba is a faster drop-in replacement for conda’s solver; the commands are identical with mamba in place of conda. If you have neither, install Miniforge, which gives you both and defaults to conda-forge.
The repository root contains environment.yml. Its key lines are:
(The real file also lists testing tools you do not need as a learner, and the Part II–IV libraries commented out.) From a terminal in the repository folder:
The first command downloads about a gigabyte and takes a few minutes; the second switches your terminal into the environment, and your prompt gains a (molecules-models) prefix. You must run the activate line in every new terminal before starting Jupyter or Python for this course.
If you do not want conda, requirements.txt lists the same pinned versions for pip. The fastest tool is uv, which creates the environment and installs into it in seconds:
Without uv, Python’s built-in venv module does the same job more slowly. Create the environment once, then activate it with the line for your operating system:
Either way you get a folder .venv inside the repository. Activate it in every new terminal, exactly as with conda.
Why pin at all? numpy==2.5.4 rather than numpy>=2 means the course pages were rendered, and the tests run, against that exact version, and that a cell which works on the website will work for you. The trade-off is that pins go stale, so the file states the one deliberate constraint in a comment: matplotlib is held at 3.10 because seaborn 0.13.2 emits deprecation warnings on 3.11, and this course treats warnings as errors. If you prefer a lock file, uv pip compile requirements.txt will produce one, but it is not needed.
With the environment active, start JupyterLab:
A browser tab opens showing the files of the repository. File → New → Notebook creates a notebook; when asked which kernelkernelThe Python process that runs notebook cells and remembers your variables between them. to use, pick Python 3 (ipykernel). The kernel is the Python process that runs your cells and remembers your variables between them, and it is the Python of the environment you activated before typing jupyter lab.
If you prefer VS Code: install the Python and Jupyter extensions from Microsoft, open the repository folder, create a file ending in .ipynb, and click Select Kernel at the top right of the notebook. Choose the interpreter inside .venv or the molecules-models conda environment. VS Code remembers the choice per notebook.
The kernel is the Python, not the terminal
Selecting the wrong kernel is the single most common local-install problem. You install everything into the course environment, open a notebook, and import pandas fails because the notebook is running the Python that came with your system, or the one from last year’s project. In JupyterLab the kernel name is shown at the top right; in VS Code it is next to Select Kernel. If it is not the course environment, change it there. The cell below shows which Python is really running:
The version should start with 3.12 (anything from 3.10 up works). To see which interpreter that is, add print(sys.executable): on your machine the path should point inside .venv or the conda environment folder, not into a system directory.
The repository ships a script that answers “is everything installed, and is it the version the course expects?” in one go. In an activated environment, from the repository folder:
In Colab, paste the file’s contents into a cell instead. A healthy run looks like this (the second line, and the exact versions, will differ on your machine):
✅ Python 3.12.14 (3.12 recommended; 3.10+ required)
/home/you/molecules-and-models/.venv/bin/python
✅ numpy 2.5.4
✅ pandas 3.1.0
✅ matplotlib 3.10.9
✅ seaborn 0.13.2
✅ scikit-learn 1.9.1
✅ joblib 1.6.0
✅ ipython (notebooks) 9.18.0
✅ jupyterlab 4.6.5
➖ rdkit (Part II) not installed (optional for now)
➖ biopython (Part III) not installed (optional for now)
➖ pytorch (Chapter 4+) not installed (optional for now)
✅ matplotlib can draw a figure
✅ scikit-learn can fit a model
All good. You are ready for Chapter 1.
How to read it:
pip install command to fix it, and the script ends with N problem(s) and exit code 1.The script’s final line names this episode’s troubleshooting section when something is wrong. You can also do the quickest possible check by hand:
Before running the next cell: sys.version printed a version above. Will sys.version_info >= (3, 10) be True on your machine? What type is sys.version_info, and why might comparing it to a tuple work?
sys.version_info is a named tuple of integers (major, minor, micro, …), and Python compares tuples element by element, so the comparison reads “at least 3.10” without any string parsing. This is exactly the test check_env.py performs.
Work through these in order; most problems are one of the first three.
python is not recognised (Windows), or opens the Microsoft
Store
On a fresh Windows machine, typing python can open the Microsoft Store because of an app execution alias. Either install Python from python.org and tick Add python.exe to PATH in the installer, or use Miniforge and the conda route, which installs its own Python. If you installed Python but the alias still wins, disable it under Settings → Apps → Advanced app settings → App execution aliases. The py launcher (py -3.12 -m venv .venv) is a reliable alternative on Windows.
ModuleNotFoundError: No module named 'pandas' after you
installed it
You installed into one Python and are running another. Run python -c "import sys; print(sys.executable)" in the terminal and import sys; print(sys.executable) in a notebook cell, and compare the two paths. If they differ, the fix is either to activate the environment before launching Jupyter or VS Code, or to select the right kernel in the notebook. Installing again from inside the notebook with %pip install pandas also works, because %pip targets the kernel’s Python by construction.
pip installs into the wrong Python
pip on your PATH can belong to a different interpreter than python. Always write python -m pip install ... (or uv pip install ...) so that the install goes wherever that python lives. If pip prints Defaulting to user installation because normal site-packages is not writeable, you are not inside an activated environment: activate it and try again.
SSL or proxy errors while downloading
Messages mentioning SSLError, CERTIFICATE_VERIFY_FAILED or ProxyError mean the download was blocked between you and the package index, usually by a corporate or university network. Try another network first (a phone hotspot is a two-minute test). If you must use the proxy, set HTTPS_PROXY in your terminal as your IT documentation describes; do not disable certificate checking.
conda hangs at ‘Solving environment’
The classic conda solver can take tens of minutes on a large environment. Use mamba (mamba env create -f environment.yml), which solves the same file in seconds; Miniforge includes it. Recent conda versions use the same fast solver by default, so updating conda itself also helps.
Apple Silicon (M-series) Macs
Everything in Part I runs natively on Apple Silicon. Make sure you installed the arm64 build of Miniforge or python.org Python rather than the Intel one running under Rosetta, which is slower and occasionally confuses compiled packages. python -c "import platform; print(platform.machine())" should print arm64.
Cells give results that make no sense
A notebook’s kernel keeps every variable from every cell you have ever run in this session, in the order you ran them, not the order they appear on the page. If you edited a cell above and did not re-run it, or ran cells out of order, the state may not match the page. Before hunting for a bug: Kernel → Restart Kernel and Run All Cells (JupyterLab) or Restart then Run All (VS Code). If the problem survives a clean run from the top, it is real.
JupyterLab opens but the kernel ‘dies’ or never connects
Usually ipykernel is missing from the environment the notebook selected, or two installations are fighting. In the activated environment run python -m pip install ipykernel (or mamba install ipykernel), then python -m ipykernel install --user --name molecules-models to register the environment as a named kernel, and pick it from the kernel list.
Green across the board
Run scripts/check_env.py in the setup you chose (as a script locally, or pasted into a Colab cell). Which lines are ✅, which are ➖, and does the last line say you are ready? If any line is ❌, use the troubleshooting section and run it again until none is.
On a correct install every essential library (numpy, pandas, matplotlib, seaborn, scikit-learn, joblib, ipython) is ✅, the three Part II–IV libraries are ➖, the two functional checks are ✅, and the final line is All good. You are ready for Chapter 1. On Colab the versions will differ from the pins and each such line carries the a different version usually works note; that is expected. jupyterlab may be ➖ on Colab, which has its own front end and does not need it. The only lines that need action are ❌ ones.
Your first notebook
Create a new notebook (JupyterLab, VS Code or Colab). In the first cell import NumPy and print its version. In the second cell, make a list of three molecule names and print how many there are. Then save the notebook as scratch.ipynb (on Colab: save a copy in Drive). Finally, restart the kernel and run only the second cell. What happens, and why?
The first two cells work as expected:
After restarting the kernel, running only the second cell still works, because it does not depend on the first. If instead you had written np.array(molecules) in it, you would get NameError: name 'np' is not defined: a restart wipes every variable and import, so anything a cell depends on must be run again first. That is the whole reason Restart and Run All is the reliable way to check a notebook.
Break it on purpose
(Local install only, optional.) In your activated environment, deliberately uninstall seaborn with python -m pip uninstall seaborn (or mamba remove seaborn), run check_env.py, then open a notebook and run import seaborn. Read the two error reports carefully: which line of the traceback tells you what is missing, and which tells you where the import was attempted? Then reinstall it (python -m pip install seaborn==0.13.2 or mamba install seaborn=0.13.2) and confirm the check is green again.
check_env.py prints ❌ seaborn not installed -> pip install seaborn==0.13.2, ends with 1 problem(s), and exits with code 1 (in a terminal, echo $? on macOS/Linux or echo $LASTEXITCODE in PowerShell shows it). The notebook shows a traceback whose last line is the error itself, ModuleNotFoundError: No module named 'seaborn', and whose lines above it point at the cell and line that tried the import. Reading a traceback bottom-up, error first and then the nearest line of your own code, is a habit the self-check practises further. After reinstalling, the check script reports all green; if the notebook still fails, you have hit the wrong-kernel pitfall, and sys.executable will show you which Python the notebook is actually using.
From here on, the environment is assumed and never discussed again: every cell in Chapter 1 runs in the setup you have just built, and every lab opens in it or in Colab with one click. When Part II arrives, the only change will be one more line in environment.yml (RDKit from conda-forge), which is why the conda route was recommended. Before Chapter 1, though, spend fifteen minutes on the self-check: it tells you whether the Python you already know is enough.