How to Install a Python Module?
Last Updated :
28 May, 2024
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.
What is a Python 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. In this article, we will see how to install modules in Python.
Prerequisites
The pip package manager is a preferred installer program to install modules in Python. We have also used pip to install a module on the computer.
If the pip is not installed then refer to the articles:
If a module is not compatible with pip, we have also shown the manual way of installing the module in Python.
Install a Python Module with pip
Below are some of the steps by which we can follow to install a Python module with pip in Windows:
Step 1: Open the Command Prompt
Open the command prompt (Windows) or terminal (Mac or Linux) on your computer.
Step 2: Installing Python Modules with Pip
Use the following command to install a module via pip, which is the package installer for Python:
pip install <module name>
Replace <module name> with the name of the module you want to install. For example, to install the popular numpy module, you would use:
pip install numpy
Note: If you are using Python 3.x, you may need to use the command pip3 instead of pip.
Once you run the command, pip will download the module from the Python Package Index (PyPI) and install it on your computer.
Step 3: Verifying Module Installation
You can now use the module in your Python code by importing it at the beginning of your script. For example, if you installed the numpy module, you would add the following line at the top of your script:
import numpy
Note: Some modules may have additional dependencies that need to be installed first. In this case, pip will automatically download and install the necessary dependencies.
That's it! You have successfully installed a Python module using pip. You can repeat these steps to install modules in Python.
Install Python Module on Windows
Output version should be equal to or greater than the 19 version, If not use the following command to update pip:
pip install --upgrade pip wheel
Output

To install Python Modules, use the following command:
pip install <modulename>
More Operations on Python Modules
Upgrade Python Modules
To upgrade the modules that are already installed, use the following command:
pip install --upgrade <modulename>
Uninstall Python Modules
To uninstall a modules that is already installed, use the following command:
pip uninstall <modulename>
Install Python Modules from Other resource
To install the modules from the other resources, use the following command :
pip install -e git+<https://github.com/myrepo.git#egg=modulename>
Installing Python Modules on Unix/macOS
Make sure that you have pip installed. Type the below command in your terminal to verify if the pip is installed or not.
python3 -m pip --version
Type the below command to install the module using pip.
python3 -m pip install "ModuleName"
More Operation on Modules in Unix/macOS
Install Specific Version of Module
To install the specific version of the module use the following command:
python3 -m pip install "ModuleName==2.2"
Install Module Version Between Two Numbers
To install the version of a module in between any two numbers:
python3 -m pip install "ProjectName>=2,<3"
Install Specific Compatible Version
To install a specific compatible version of full length:
python3 -m pip install "ModuleName~=2.2.3"
Upgrade Module
To upgrade the project version use the following command:
python3 -m pip install --upgrade ModuleName
Install Required Module from Text Document
To install a required module that is in the text document:
python3 -m pip install -r requirements.txt
Install Directories Present in Local System
To install the directories that are present in the local system using 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
Update a Package
To update the installed pip and setup tools copies use the following command:
python -m pip install --upgrade pip setuptools wheel
Manual Installation of Python Modules
The majority of Python modules 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 module is not present there then use the following command to install the module using the command manually:
python <FILE_NAME>.py install
So we have covered how to install a module in Python. We have show the methods to install modules using pip package installer and manually using .py install method.
Read more articles on Python Module:
Similar Reads
Python Tutorial | Learn Python Programming Language Python Tutorial â Python is one of the most popular programming languages. Itâs simple to use, packed with features and supported by a wide range of libraries and frameworks. Its clean syntax makes it beginner-friendly.Python is:A high-level language, used in web development, data science, automatio
10 min read
Python Interview Questions and Answers Python is the most used language in top companies such as Intel, IBM, NASA, Pixar, Netflix, Facebook, JP Morgan Chase, Spotify and many more because of its simplicity and powerful libraries. To crack their Online Assessment and Interview Rounds as a Python developer, we need to master important Pyth
15+ min read
Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
Python OOPs Concepts Object Oriented Programming is a fundamental concept in Python, empowering developers to build modular, maintainable, and scalable applications. By understanding the core OOP principles (classes, objects, inheritance, encapsulation, polymorphism, and abstraction), programmers can leverage the full p
11 min read
Python Projects - Beginner to Advanced Python is one of the most popular programming languages due to its simplicity, versatility, and supportive community. Whether youâre a beginner eager to learn the basics or an experienced programmer looking to challenge your skills, there are countless Python projects to help you grow.Hereâs a list
10 min read
Python Exercise with Practice Questions and Solutions Python Exercise for Beginner: Practice makes perfect in everything, and this is especially true when learning Python. If you're a beginner, regularly practicing Python exercises will build your confidence and sharpen your skills. To help you improve, try these Python exercises with solutions to test
9 min read
Python Programs Practice with Python program examples is always a good choice to scale up your logical understanding and programming skills and this article will provide you with the best sets of Python code examples.The below Python section contains a wide collection of Python programming examples. These Python co
11 min read
Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
Python Data Types Python Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, Python data types are classes and variables are instances (objects) of thes
9 min read