How to Manually Install Python Packages?
Python is one of the most famous and powerful languages in the world. It is a dynamically typed, high-level interpreted language intended for general use. Python first made its public appearance in the year 1991, which means it is a fairly old language. It was designed by Guido Van Rossum and developed by a non-profit organization called the Python Software Foundation. Two reasons for its popularity are listed below:
- Python’s constructs and its support for the multi-paradigm approach support programmers in writing clean & concise code consisting of small logic.
- The second reason for its worldwide popularity among developers is the amount of community support this language has received. And one of the many benefits of this support has been the availability of over 300,000 packages for python. These packages are the main strength of python because it lets developers do all sorts of things that a language is capable of ranging from simple graphics using Tkinter to making a video out of plain text using the movie.py package.
To use these packages with python it first needs to be installed on the system. There are a couple of ways to do the same. The most popular one is with the help of pip (package manager). But is this article we are going to do it manually without the help of any package manager. Which can be helpful in case the package to be installed is not supported by pip or any other reason.
Step 1: Install Python
So, if we are supposed to install a python module manually the first obvious prerequisite would be to install the Python source code which comes along with its interpreter. To install Python we first, need to visit the website python.org and click on the downloads tab. From the downloads tab, we can get the latest version of python.
Once it is downloading is complete we need to click it open. Now once the installer is opened we can select the option accordingly and proceed by clicking the next button.
At we will be shown the default installation location for python. We can either change it or better leave it as it is. But we need to copy the path so as to use the further steps.
And at last, we can click on the install button.
Once the installation is complete we can open the command-line tool or terminal and run the command below to check the proper installation of the python.
If python has been installed properly it would return the version number.
Step 2: Download Python Package From Any Repository
Once we are done with python installation we can download any python package of our choice. Here we have downloaded pyautogui which is a python package that helps developers instruct and automate certain aspects of GUI such as gesture detection and else.
We are downloading pyautogui package source code from github as a zip file.
Step 3: Extract The Python Package
After we have the zip file of the python package we need to extract it in the location of our choice and search for the main package folder inside, which shares the same name as the package itself.
Step 4: Copy The Package In The Site Package Folder
Once we have found the main package folder from the extracted repository we have to place it in the reach of the python so as to facilitate its interaction. And the location where we need to place this package folder is the site packages folder which one would find in the Lib folder at the location where the python is installed. The address is given below for your convenience:
C:\Program Files\Python39\Lib\site packages
All we need to do is to locate the address above and paste the python package folder there.
Step 5: Install The Package
After placing the package folder in the reach of python that is in the site packages folder, we have to tell python that a package has been served to its reach and it needs to import it for further use. And this can simply be done by running the below command in the terminal.
import "package name" Example: import pyautogui
So the five steps that are mentioned above conclude all that is there in order to import a python package manually without using any package manager.
Please Login to comment...