liveBook · Manning

Dependency

As explained in The Quick Python Book, Fourth Edition

A software dependency is an external software component or prerequisite that an application or package needs to build or operate.

A dependency is an external software component or prerequisite that an application needs to build or operate. In Python, dependencies commonly take the form of third-party packages or modules installed before they can be imported. section 10.6 section 19.5

Working with dependencies usually involves these practical decisions:

  • Find a package suited to the task, then assess its source, quality, security, and functionality before trusting it. section 1.2.5 section 19.3
  • Install third-party modules into a directory on Python’s module search path before importing them. section 10.6
  • Choose an installer or package manager when it can resolve dependencies and handle complex build requirements. section 19.3
  • Watch for version conflicts: prebuilt operating-system packages may be older and less flexible than other installation options. section 19.3

Installing a pinned dependency

Install the requests package with pip, upgrade it when needed, or constrain the installed version: python3 -m pip install requests; python3 -m pip install --upgrade requests; python3 -m pip install requests==2.32.3. In Colaboratory, prefix the command with !. section 19.5

$ python3 -m pip install requests

Use the command listing to see the basic pip form for adding a Python dependency. section 19.5

How The Quick Python Book, Fourth Edition covers it

How deep it goes
Explains discovery, installation, importing, dependency resolution, version constraints, and package trade-offs without detailing dependency internals.
Examples
Demonstrates installing, upgrading, and version-pinning requests with pip, including Colaboratory command syntax.
What it assumes
Assumes Python installation and general programming knowledge while distinguishing standard-library modules from separately installed third-party modules.
What you can do after
Apply dependencies via pip by installing packages, upgrading them, and specifying acceptable or exact versions.
How it connects
Connects dependencies with third-party packages, modules, imports, the Python Package Index, pip, package managers, and virtual environments.

Also explained in

Compare how 27 books explain dependency →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Quick Python Book, Fourth Edition. The section links point to the parts of the book it draws on.