ErrLookupBackground articles › "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed

"X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed

"The X package is not installed. Please install it with pip install X" — this error family covers ImportError, ValueError, and RuntimeError messages raised when a library lazily imports an optional dependency (an extra, a separate distribution, or a vendor-only package) that is not present in the running environment. Developers meet it at first use of a feature — enabling a callback, constructing an embedding function, saving a file, or logging in — on slim Docker images, fresh venvs, pruned npm installs, or machines where the base package was installed without its extras.

Distilled from 119 documented records across 22 repositories.

Background

Libraries keep their install footprint small by declaring heavyweight or niche integrations as optional dependencies: pip extras (litellm[grpc], yt-dlp[default]), optionalDependencies in package.json, or separate distributions entirely (litellm-enterprise, sgl-kernel). The code that needs such a dependency typically wraps its import in a try block or a soft-import guard at module load, caches the failure, and later re-raises it as a friendlier error — ImportError chained via 'raise ... from exc', or converted to ValueError/RuntimeError — with an explicit install instruction. That is why the message reads like the opening of record [5]: "The boto3 python package is not installed. Please install it with `pip install boto3`".

From the caller's side the failure almost never happens at import time of the host library; it fires lazily at the moment the feature is exercised. LiteLLM raises OTel exporter errors while building span/metric/log providers at startup ([3], [4], [9], [10], [14], [19]), but its NVIDIA Riva error only appears on the first transcription call ([24]). Chroma raises ValueError in an embedding function's constructor, before any embedding is computed ([5], [11], [16], [18], [29]). Angular's ServerXhr is a variant: the failure is a race/state error ('XHR implementation is not loaded') caused by a lazy dynamic import of xhr2 that never completed ([6]), and npm-ecosystem libraries see the same family when optionalDependencies are pruned at install time, as with GitNexus's onnxruntime-node whose postinstall could not download CUDA binaries ([1]).

The family also includes genuinely unavailable dependencies, not merely uninstalled ones. LiteLLM's 'enterprise folder' callbacks ([2], [15]) can never be satisfied by pip because the enterprise package ships only inside the official Docker image, and the litellm-enterprise callbacks ([0], [7], [28]) additionally gate on a license after the import succeeds. Some members are conditional capability checks rather than missing packages: matplotlib raises 'cairo has not compiled with SVG support' when the installed native cairo lacks a surface ([26]), nautilus_trader demands pandas only when a nanosecond remainder would lose precision ([21]), and yt-dlp's ivi.ru extractor reports the missing crypto module only after the signed request path it would have enabled was skipped ([20]). A few libraries attempt auto-install — ruflo's AIDefence loader tries once per process and permanently short-circuits after a failed attempt, requiring a restart ([12]).

Common causes

What usually fixes it

Go deeper

Documented occurrences

…and 99 more across the corpus — use search.

Honest provenance: generated on 2026-08-28 from AI-assisted analysis of the linked records. See how records are made.