Safeguard
Supply Chain•

Are Python packages installed with apt missed by a pip scan?

Python libraries installed through the OS package manager do not appear in requirements files, so a pip focused scan misses them. Where to look instead.

Safeguard Security Team
3 min read

Yes, often. A Python library installed with the operating system package manager is tracked by that manager, not by your requirements file, so a scan of pip manifests never lists it. An image or host level scan that reads the OS package database does see it.

Two package managers, two records

When you run apt install python3-requests, the library lands in the system Python directories and is recorded in the OS package database. Your requirements.txt says nothing about it. A scanner that parses Python manifests sees only what the file lists.

PEP 668 explains why the split exists. It defines a way to mark a Python base environment as externally managed, so that installers like pip refuse to modify packages the OS manager owns, avoiding conflicts such as externally installed packages being deleted. It recommends guiding users toward virtual environments. The result is two worlds: the system environment managed by the distribution, and project environments managed by pip.

Why it matters for scanning

Where the library came fromRecorded inSeen by pip manifest scanSeen by image or host scan
requirements.txt installManifest and site packagesYesOften
Virtual environmentLockfile if you keep oneYesSometimes
OS packageOS package databaseNoYes

If your app, or a tool in the same image, imports a system library, an advisory against it will not appear in your Python results. It may appear instead as an OS package advisory, under a different package name such as the distribution's own python3- prefix, which complicates matching.

How to check your own images

  1. Open a shell in the built image.
  2. List OS packages with names starting with python3-, using your distribution's package listing command.
  3. List pip installed packages from the interpreter your app uses.
  4. Compare. Anything in the first list and not the second is invisible to a manifest scan.
  5. Decide whether the app actually imports it.

Reducing the gap

  1. Use a virtual environment for application dependencies, and keep a lockfile.
  2. Avoid installing Python libraries through the OS manager in application images, unless the distribution's tested version is deliberately wanted.
  3. Always run an image level scan as well as a manifest scan. See scan conda and pip environments for known vulnerabilities.
  4. When an advisory names a Python library, search both lists.

Which one is patched by whom

OS packages are patched by the distribution through updates to the image. Pip packages are patched by you, through the lockfile. Knowing the source tells you who fixes it. See does the scanner cover containers and base images.

Safeguard offers SBOM and dependency scanning and a free scan at gold.safeguard.sh/scan. Use both manifest and image views for Python workloads.

Quick check

Does PEP 668 stop pip from touching system packages?

It lets distributions mark the environment as externally managed, so pip warns or refuses by default. Details depend on the distribution.

Which scan should I trust for a Python container?

Use both. The manifest scan sees your pinned libraries, and the image scan sees OS level ones.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.