How to Install a Python Module?

06 Oct, 2021
A module helps you to arrange your Python code logically. The code is easier to understand and use when it is organized into modules. You can bind and reference a module, which is a Python object with arbitrarily named attributes. 
A module is simply a file containing Python code. Functions, groups, and variables can all be described in a module. Runnable code can also be used in a module. A module can be imported by multiple programs for their application, hence a single code can be used by multiple programs to get done with their functionalities faster and reliably.
Check pip is installed or not: To check whether pip is installed or not, run the following command in windows using the command prompt:
pip --version 
Output:
Note: If the pip is not installed then refer to the article How to install PIP on Windows ?
Output version should be equal or greater than 19 version, If not use the following command to update pip:
pip install --upgrade pip wheel
Output:
To install the pip package use the following command to install the required package:
pip install <packagename> 
To install the packages from the other resources, use the following command :
pip install -e git+<https://github.com/myrepo.git#egg=packagename>
To upgrade the packages that are already installed, use the following command:
pip install --upgrade <packagename>
To uninstall a package that is already installed, use the following command:
pip uninstall <packagename>
Make sure that you have pip installed. Type the below command in your terminal verify if the pip is installed or not.
python3 -m pip --version
Note: If the pip is not installed then refer to the article
How to install PIP in Linux?
How to install pip in macOS ?
To update the installed pip and setup tools copies use the following command:
python -m pip install --upgrade pip setuptools wheel
Type the below command to install the module using pip.
python3 -m pip install "ProjectName"
To install the specific version of the module use the following command:
python3 -m pip install "ProjectName==2.2"
To install the version of a module in between any two numbers:
python3 -m pip install "ProjectName>=2,<3"
To install a specific compatible version of full length:
python3 -m pip install "ProjectName~=2.2.3"
To upgrade the project version use the following command:
python3 -m pip install --upgrade ProjectName
To install a required module that is in the text document:
python3 -m pip install -r requirements.txt
To install the directories that are present in the local system use the following command:
python3 -m pip install --no-index --find-links=file:///local/dir/ ProjectName
python3 -m pip install --no-index --find-links=/local/dir/ ProjectName
python3 -m pip install --no-index --find-links=relative/dir/ProjectName
The majority of Python packages are now designed to work with pip. If you have a kit that isn’t compatible, you’ll have to install it manually.
Install the kit by downloading it and then extracting it to a local directory. If the kit has its own set of installation instructions, obey them, if the package is not present there then use the following command to install the package using the command manually:
python <FILE_NAME>.py install
how-to-install
Picked
Python-pip
How To
Installation Guide
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Set Git Username and Password in GitBash?
How to Install Jupyter Notebook on MacOS?
How to Install and Use NVM on Windows?
How to Install Python Packages for AWS Lambda Layers?
How to Install Git in VS Code?
Installation of Node.js on Linux
Installation of Node.js on Windows
How to Install Jupyter Notebook on MacOS?
How to Install and Use NVM on Windows?
How to Install Python Packages for AWS Lambda Layers?