Modules, Packages, Libraries - What's The Difference?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what is going on guys welcome back in this video today we're going to learn what the differences are between libraries packages and modules in Python so let us get right into [Music] it all right so this is going to be quite simple and straightforward we're going to learn what the differences are between libraries packages and modules in Python today now when I open a terminal and install something using pip so when I say pip or pip 3 install I usually say that I'm installing an external python package however this might actually not always be 100% correct because sometimes I might actually be installing a library and I often times say we import a package we import a library we import a module and I'm not necessarily always using the correct terminology 100% of the time which I don't think is a problem I'm going to continue to do it the way I do it but in this video today you are going to learn the exact correct terminology for these three things when to use what so let's start right away with a simple structure here the basic idea is that a model is a python file with some functionality classes functions methods and so on and then a package contains multiple modules and a library contains multiple modules and packages so we can start by saying I have my lip here and in my lip I have a directory package one for example then I might have package two and package three and inside of the packages I can have some module one I can have a module two I can have a module 3 of course you can call them whatever you want here these are just example names and there you go and then also I might have outside of this Library a script a script is a python file that is meant to be run uh so that you can actually execute some code so main py is not a package not a module not a library it's a script so the basic idea now is that each package contains a so-called init file socore init uncore py that is what marks this as a package so I can just put it here put it here and also put it here and then also I can have here another module without a package so I can have some module py also outside of the packages and this is now the structure and these are names you should be using if I'm in my script and I'm importing something if I import my lip I'm importing a library if my lip is something that I can install using pip I'm installing a library that contains multiple packages and modules if I import my lip. package one I'm importing a package from my lip and I can of course also say from my lip import package one that is a package that I'm importing here I can also import from my lip package one I can import a specific module all of it so the full module and then of course this module might have multiple functions I can have my function one in here which returns hello and I can copy it I'm can to have a my function two and the my function two returns world for example and I can also just import specific functions from the module of the package of the library so I can say from myp package one module One Import and then my function one then I can call it like this so that is the basic difference here um maybe to understand this a little bit better let's go ahead and use matplot lip as an example here matte PL lip itself is a library actually has it in the name already it has a lip at the end which stands for Library so matplot lip in and off itself is a library now matplot lip has multiple packages I can say matplot lip Dot and you can see we have modules which are here with the python symbols but we also have this directory symbol here which is actually uh a package so for example mtpl lip. backends it's a package and then I can press uh dot again and you can see we have multiple modules here so back end of qt5 for example um and of course you can have packages and packages I don't know if we can find something like this here maybe mat lip do axis no we don't have this here uh matp lip dot not sure if we're going to find this maybe in the backends maybe in no okay uh but if you have packages and packages you can do the same thing so you would have something like uh library. package one. package or I could say sub package one module something like this so that is the basic idea you have individual python files with classes with functionality uh with stuff to import that's a module the script you use to import all this and use all this is the script and then you have packages which are directories that contain one or multiple modules and also in a nit file and then you have libraries if you have multiple packages and uh modules so you could also just have a single package and you can also just publish a package and then you can install it using pip but if you have a library with multiple packages and modules and subpackages and so on that is a library not a package so that's it for today's video I hope you enjoyed it and hope you'll learn something if so let me know by hitting a like button and leaving a comment in the comment section down below and of course don't forget to subscribe to this Channel and hit the notification Bell to not miss a single future video for free other than that thank you much for watching see you on the next video and bye
Info
Channel: NeuralNine
Views: 5,088
Rating: undefined out of 5
Keywords: modules, packages, libraries, python, differences, modules vs packages, package vs library
Id: GUXxLy68EF8
Channel Id: undefined
Length: 6min 8sec (368 seconds)
Published: Mon Mar 11 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.