How to install Python modules?
Before we get started, let's have a glimpse at the basics of Python modules. What are Python modules? Why is it used? The doubts of a beginner goes on... That's absolutely fine. Doubts are the key tool of a programmer. Okay, let's get started.
In programming, we often reuse code that we've written or someone else has written. This is called code reuse and nearly all languages provide some way of doing it. There are also Functions that let us group code into logical blocks that can be executed at a later point and as many times as we need. But as our scripts get bigger and more complicated, we want to be able to reuse more than a single function. We might even want to reuse entire scripts and other programs that we write. This is where Python modules come in to play. Modules can also be defined as a file containing Python code which can define functions, classes, and variables. These modules can be imported to your program when needed.
To use Python modules, you must first set up Python Environment in your machines. For this check out
How to set up Python Environment in Windows
How to set up Python Environment in Linux
How to set up Python Environment in macOS
Once you finished setting up Python Environment it doesn't mean that you have the modules you might need for every possible script. For this you must install the desired module. Let's check how to install a Python module.
Note: Here module_name represents the name of the module.
While using this method, we first need to make sure that we have Python 3 version of pip which is called pip3.
![File:Python-logo-notext.svg - Wikimedia Commons](https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Python-logo-notext.svg/1200px-Python-logo-notext.svg.png)
To use Python modules, you must first set up Python Environment in your machines. For this check out
How to set up Python Environment in Windows
How to set up Python Environment in Linux
How to set up Python Environment in macOS
Once you finished setting up Python Environment it doesn't mean that you have the modules you might need for every possible script. For this you must install the desired module. Let's check how to install a Python module.
Note: Here module_name represents the name of the module.
1. WINDOWS
- Open Command Prompt and run the following command.
2. LINUX
Method I
- Open Terminal and run the following command.
Method II
- To install pip3, open Terminal and run the following command.
- Once the installation is complete, run the following command in Terminal to install the desired module
Note: If pip3 is already installed in your system, you can directly proceed to Step 2.
3. macOS
- Open Terminal and run the following command.
Hurray!! The modules are now ready to use. We will be sharing some cool Python codes for our users to try. Get ready to code!!
C O D E W I T H B I N A R Y P A G E S
Comments
Post a Comment