Libraries Packages and Modules in Python

You must have heard and used so many libraries, packages, and modules in Python. You should have started most of your programs by importing them. In this article, I’m going to give you an introduction to libraries, packages, and modules in Python and what the difference between them is.

Libraries, Packages and Modules in Python

Libraries:

Libraries in Python are all that you get when you download and install the Python programming language in your system. So this means that the standard Python library includes everything in Python like all data types, classes, and objects.

Also, Read – 100+ Machine Learning Projects Solved and Explained.

Simply put, the standard library includes functions, classes and objects, data types, and everything else we use when writing a program.

Packages:

The Python programming language is an open-source programming language that supports modular programming, which means every Python programmer doesn’t have to reinvent everything on their own. The best part about Python is that even the largest projects can be broken down into smaller parts.

So what happens when we are working on a big project we need some code already created by someone in the world to automate some common tasks. So while working in a large project, whether in a team or alone, you can use some code that has already been written and contributed by someone.

So the packages that we hear in Python are exactly that part of code which are contributed by someone already. There are thousands of Python packages available online. You can also create your package and contribute it among the coding community. To use a package in Python we need to install it by using the pip command; pip install package name.

Modules:

You must have heard of modules while learning Python. A module is a big part of what makes Python a modular programming language. As while working with modules we use the code which is grouped according to a particular defined function. For example, the DateTime module helps you to work with date and time.

Summary

Let’s understand the difference between libraries, packages, and modules in Python. If we think of a standard Python library as the actual physical library, then a package is like a book within that library, and a module is like chapters within a book.

So to conclude, we can say that a package is a collection of modules and that a library is a collection of packages. Hope you liked this article on what libraries, packages and modules are in Python. Please feel free to ask your valuable questions in the comments section below.

Aman Kharwal
Aman Kharwal

I'm a writer and data scientist on a mission to educate others about the incredible power of data📈.

Articles: 1498

Leave a Reply