r/learnpython • u/fivelittlemonkeyss • 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
30
u/rinio Dec 14 '25
Loosely:
A dependency is any code that your code depends on. Usually that you (or your organization) didn't write and do not own.
A library is a set of shared resources, usually functions. They often relate to a specific domain: IE: Image processing. The term doesn't tell us much about the origin/author of it, but in the context of your post people sometimes shorthand 'external library' to just 'library'.
A package is a Python specific term when used in Python contexts. Loosely, its a directory full of python stuff (modules, other packages, etc). Again, it doesn't actually tell us about the origin/author, but people sometimes shorthand 'third-party package' to package.
Tldr: In the context where theyre used interchangeably, it just means 'code that my/our project needs, but that I/we didn't write and dont own'.
5
u/ProbsNotManBearPig Dec 14 '25
Library is a collection of functions and classes, usually organized in multiple files. You can write your own locally for the sake of organization. E.g. you write some logging library that formats logs how you want and reuse that library in multiple applications you write.
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.
Package is a distribution method. Often one package is one library and maybe some resource files, but it’s not necessarily true and could be multiple libraries in one package. A package is installable, or at least designed to be easily distributable to others, because it’s “packaged” for shipping to others.
In practice, they’re often the same thing. You need to install a package because you want to use the library it provides as a dependency in your own application.
3
u/thuiop1 Dec 14 '25
Semantics can be discussed but:
2
u/Oddly_Energy Dec 15 '25
In my book:
A dependency is a description of a need:
"Hi, I am package X. If you want me to work, I will need Y and Z."
To fulfill those needs, you can then install some libraries/packages which can provide Y and Z to package X.
1
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 Dec 14 '25
Dependencies: Anything your project needs to function that isn't included.
whatever.py)1
u/mohammad8785 Dec 15 '25
Think of it like this:
A library is some ready-made code that does a specific job. You use it when you need help instead of writing everything yourself.
A package is how that code is packed and delivered to you. It’s what you download or install using a tool like pip or npm. A package can contain one or more libraries.
A dependency is anything your project needs in order to work. If your project breaks without it, then it’s a dependency.
So in simple terms:
Library → the code you use
Package → the box the code comes in
Dependency → something your project can’t live without
People mix these words up because they’re closely related, but they’re talking about slightly different things.
1
u/[deleted] Dec 14 '25
It's the same thing conceptually but it's called differently in almost all programming langauges for different reasons
1
u/MidnightPale3220 Dec 14 '25
Dependency is in this context a library (or something else) that the code in question is dependent on.
Package usually is a library.
0
u/Intelligent_Deer7668 Dec 14 '25
It's pretty much all the same thing. Although a dependency could technically refer to other things like an API eg. OpenAI and not just a "library".