How to install packages/modules in colab? - python3

 How to install packages/modules in  colab

Google Colab/colaboratory is a free Jupyter notebook environment that runs entirely in the cloud. Most importantly, it does not require a setup and the notebooks that you create can be simultaneously edited by your team members,it is one of the top service provided by google in to tech industry💓

from google.colab import drive

import os

import required modules -->most of the library/modules are available in colab(so we don't need to install it manually - just import and we are free to start )
in case if the module is not available we have to manually install it 

I'm working on a project in which i want to create chunks of  a .wav file 
(cutting a single wav file into multiple wav file of small size )
6sec single audio into >> four 1.5 sec audio (6/1.5=4)  
for that purpose i need to import "pydub" module which is not available in colab ,
So we can add it  simply by using the following command💫
 

!pip install pydub

 
yaah..as simple as this!💥
 
we can keep it as our first line of code, so when ever we run the code it it will do this  installation first , if requirement already satisfied - obviously it will skip this line.
That make our code more easy to share -- we can just copy and send the code --
feel like sharing our virtual environment folder , The next person can simply paste the code in his/her colab and BooM! It will install the package and start running without any issues.
 
so the code will be like

 Python code :

!pip install pydub
from google.colab import drive
import os
from pydub import AudioSegment
from pydub.utils import make_chunks