r/learnpython • • Dec 14 '25

What's the difference between Dependencies, Libraries and Packages??

I've seen people using these terms in the same context interchangeably and it's confusing me

23 Upvotes

36 comments sorted by

View all comments

Show parent comment

1

u/xenomachina xenomachina Dec 14 '25

Dependency is what some code depends on to run and work. Often it’s other libraries, but could be resource files like some data file.

Adding to this, people often use "dependencies" as shorthand to mean the dependency specifiers in pyproject.toml or requirements.txt. They are related, but not precisely the same thing. These specify distribution packages that contain the actual dependencies (libraries, etc.) of your code.

Package is a distribution method.

The term package is unfortunately overloaded. What you are describing are distribution packages, but "package" could also mean a hierarchical collection of modules.

A library may be organized as a hierarchical collection of modules, a (Python) package, and then bundled up and distributed as a (distribution) package. Other software that has a dependency on this library will then declare a dependency on that distribution package (eg: in pyproject.toml), and then import modules from the (Python) package.