Before reading this article you must have pip in your path installed in your system!
Go and read this to add pip to your path.(environment variables)
Sometimes we have to use someone else's code in our program, as it saves us a lot of time. Today we will get acquainted with the technique of using code that was not written by us, but will improve the quality of our program, save time and, of course, legally and free of charge.
Module/Libraries - A module or library is a file containing the definitions of several functions, classes, variables, etc., written for us by someone else.
Pip - Pip is a package manager for Python i.e. pip command can be used to download any external module in Python. This is what helps us get the code written by someone else.
We can install a pip command control module on your system.
- Open terminal into your system.
pip install module_name
- Then type pip install module_name and press Enter.
Once this is done, the module will start downloading and will be automatically installed on your computer.
For example, let me show you how to install numpy
pip install numpy
After doing this numpy will be installed in my system!
After installing any module in Python, you can import it into your Python program or project. For example, to use numpy, I would write "import numpy" at the top of my Python program
This will import numpy in our program...
There are two types of modules/Libraries in Python:
- Built-in modules:
The built-in module is a pre-installed module in Python. No need to download before use. This module comes with a python translator.
Examples - random, os, etc.
- External module:
This is a module that is not pre-installed in Python, i.e. we need to download it before using it in our program.
Examples - numpy, pandas, TensorFlow, etc
These modules are written by somebody else to help us write our code faster..
We can use the functions, variables, classes, etc from these modules to our code!