Skip to content

networks.md imports quantecon without installing it, relying on earlier lectures' pip cells #801

Description

@mmcky

lectures/networks.md imports quantecon but never installs it. Its pip cell at line 19 installs only quantecon-book-networks==1.6 and pandas-datareader, while line 56 does import quantecon as qe.

It works today because three earlier lectures in the TOC install quantecon into the same runner environment, and pip installs persist across notebooks within a build:

TOC position Lecture pip cell
35 markov_chains_I !pip install quantecon
36 markov_chains_II !pip install quantecon
40 eigen_II !pip install quantecon
43 networks !pip install quantecon-book-networks==1.6 pandas-datareader

So networks.md has an implicit dependency on lecture execution order, and a full cold build satisfies it by accident.

When it stops working

The moment networks.md executes without those earlier lectures also executing. That is not hypothetical — it is the normal case whenever the build cache is warm and only this lecture changed. jupyter-cache re-executes the notebooks whose content changed and reuses the rest, so a one-line edit to networks.md runs it in an environment where none of the earlier pip cells have fired.

Observed in the Chinese edition (lecture-intro.zh-cn#276): an unrelated edit to a code cell in networks.md produced

ModuleNotFoundError: No module named 'quantecon'

at line 5 of the imports cell, with every other lecture served from cache. The lecture had been building green for months.

Suggested fix

Add quantecon to this lecture's own pip cell, so it is self-sufficient:

!pip install quantecon quantecon-book-networks==1.6 pandas-datareader

That matches the convention already used elsewhere in this repo — packages outside the anaconda distribution are installed at the start of the lecture that needs them — and removes the ordering dependency entirely.

Worth a wider check: any lecture that imports a non-anaconda package it does not itself install has the same latent fault, and it will stay invisible until that lecture is edited in isolation.

Found while reviewing figure-font handling across the translation editions; the Chinese edition carries the identical gap because it is a faithful translation of this file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions