Install required packages automatically for a python script

Posted by

it is a hard to install all the libraries one by one. Each time you have to find out the name of the library and install it one by one. But if we know libraries like pipreqs which automatically installs all the required libraries to run the program

What is Pipreqs?

It is a python library that Generates pip requirements.txt file based on imports of any project and then you can install all of them in one go.

Join Our Discord Hacking Server: 

Invite Our Cybersec Bot:

Step 1: Go to the directory in which your python script is present for example assume if we take this code in our directory. Let’s assume that your Python script is

import os
import time
import sys
import fnmatch
import requests
import urllib.request
from bs4 import BeautifulSoup
from multiprocessing.dummy import Pool as ThreadPool 

You can use pipreqs to automatically generate a requirements.txt file based on the import statements that the Python script(s) contain. To use pipreqs, assuming that you are in the directory where is located:

Installing Pipreqs:

Run this command on your PC to install the pipreqs library.

pip install pipreqs


It will generate the following requirements.txt file. The requirement file will look like this in our case.


which you can install with:

pip install -r requirements.txt

Other useful command…

Use pip list to get a full list installed python packages.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.