Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
How to Install Python Six Module on Linux?
Next article icon

How to Install a Python Module?

Last Updated : 28 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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:

  • How to install PIP in Linux?
  • How to install pip in macOS?
  • How to install pip in Windows?

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

Install a Python Module

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:

  • Basics Of Python Modules
  • Create and Import modules in Python
  • External Modules in Python
  • Python Packages


Next Article
How to Install Python Six Module on Linux?
author
kandulasundar3036
Improve
Article Tags :
  • How To
  • Installation Guide
  • Python
  • how-to-install
  • Python-pip
Practice Tags :
  • python

Similar Reads

  • How to Install Python py-asn module on Linux?
    Py-asn is a Python library that is considered as the extension library which activates very fast Internet Protocol addresses to Autonomous System Number lookups. We can also perform current state and historical state lookups with the help of this package. Input given to this package is MRT/RIB BGP a
    2 min read
  • How to Install Python py-asn module on MacOS?
    Py-asn is a Python module called an extension module. It provides/enables fast IP addresses for autonomous system number lookup. It can search current and historical states using included packages. Inputs can be archived as MRT/RIB BGP. The module is written in C and Python and can be compiled acros
    1 min read
  • How to Install Python py-asn module on Windows?
    Py-asn is a Python module that is said to be an extension module. It provides\Enables a fast IP address to Autonomous System Numbers Lookups. It can perform both Current state and Historical state lookups with help from its contained packages. Input can be given as MRT/RIB BGP archive. The module is
    2 min read
  • How to Install Python Six Module on Linux?
    Six is a Python library that is used to wrap the differences between Python 2 and Python 3 for those systems that work on both Python 2 and Python 3. It is compatible with both Python 2 and Python 3 and can only contain one Python file which makes it easier to add to your projects. In this, article,
    2 min read
  • How to create modules in Python 3 ?
    Modules are simply python code having functions, classes, variables. Any python file with .py extension can be referenced as a module. Although there are some modules available through the python standard library which are installed through python installation, Other modules can be installed using t
    4 min read
  • How to Install Python3 on AWS EC2?
    AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual com
    3 min read
  • How to Install psycopg2 Binary Module in Python ?
    psycopg2 is the most popular PostgreSQL database adapter for the Python programming language. It is a DB API 2.0 compliant PostgreSQL driver that is actively developed. It is designed for heavily multi-threaded applications that create and destroy lots of cursors and create a large number of "INSERT
    1 min read
  • How to Install Python Emojis module on MacOS?
    Today, everyone uses social media and messaging apps like Facebook, Instagram, and Whatsapp, and every app has emojis that we can use to share our moods and enhance our boring messages. Now, the same gem can also be used in our Python programs for enhancing our output. In this article, we will see a
    2 min read
  • How to Install Python on Linux
    This guide explains how to install Python on Linux machines. Python has become an essential programming language for developers, data scientists, and system administrators. It's used for various applications, including web development, data science, automation, and machine learning. This comprehensi
    15+ min read
  • How to Install mechanize for Python?
    In this article, we are going to install mechanize for Python. Mechanize was designed by John J. Lee. and Maintenance take over by Kovid Goyal in 2017. It follows the Stateful programmatic web browsing in Python Features of mechanize moduleMechanize browser implements the interface of urllib2.Opener
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences