whatisgithub

What is pipreqs?

bndr/pipreqs — explained in plain English

Analysis updated 2026-06-24

7,452PythonAudience · developerComplexity · 1/5Setup · easy

In one sentence

A Python command-line tool that scans your project's source files and generates a requirements.txt listing only the packages your code actually imports, not everything installed on your machine.

Mindmap

mindmap
  root((pipreqs))
    What it does
      Scan import statements
      Generate requirements.txt
      Clean unused deps
    Commands
      pipreqs path
      --diff flag
      --clean flag
    Options
      Ignore directories
      Pin exact versions
      Flexible ranges
    Support
      Python files
      Jupyter notebooks
    Install
      pip install pipreqs
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Generate a clean requirements.txt for a Python project listing only the packages the code actually uses

USE CASE 2

Check whether an existing requirements.txt is out of sync with what your code imports using the --diff flag

USE CASE 3

Remove stale package entries from requirements.txt automatically when you stop using a dependency

What is it built with?

Pythonpip

How does it compare?

bndr/pipreqssamuelclay/newsblurluckyone7777/llm-trading-lab
Stars7,4527,4577,458
LanguagePythonPythonPython
Setup difficultyeasymoderatemoderate
Complexity1/54/53/5
Audiencedevelopergeneralresearcher

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

So what is it?

pipreqs is a command-line tool for Python projects that automatically figures out which third-party packages your code actually uses and writes them to a file called requirements.txt. That file is the standard way Python projects list their dependencies so someone else can install everything needed to run the code. The standard approach most people know is "pip freeze," which lists every package installed on your computer. The problem is that gives you everything, including packages from other projects you have installed, not just the ones your current project needs. pipreqs solves this by scanning your actual source code files, finding the import statements, and figuring out from those which packages to include. You point it at a folder and it produces a clean, project-specific requirements file. Usage is straightforward. You run "pipreqs /path/to/your/project" and it creates the requirements.txt file in that folder. A handful of options let you customize the behavior: you can ignore certain subdirectories, skip symlinks, force-overwrite an existing file, or print the results to the terminal instead of saving them. There is also a mode option for controlling whether the output pins exact version numbers or uses more flexible version ranges. A comparison and cleanup feature rounds out the tool. The "--diff" flag checks whether your existing requirements.txt matches what your code actually imports, and "--clean" removes entries from requirements.txt that are no longer imported anywhere in your project. Support for Jupyter notebook files is optional and can be turned on with a flag. The project is installable via pip in one line. The README notes the project is looking for maintainers to keep it moving forward.

Copy-paste prompts

Prompt 1
How do I use pipreqs to generate a requirements.txt for my Python project in the src/ directory?
Prompt 2
My requirements.txt has packages I no longer use, how do I run pipreqs --clean to remove them automatically?
Prompt 3
How do I run pipreqs on a project that includes Jupyter notebooks and include their imports in requirements.txt?
Prompt 4
What is the difference between pipreqs and pip freeze, and when should I use each one?

Frequently asked questions

What is pipreqs?

A Python command-line tool that scans your project's source files and generates a requirements.txt listing only the packages your code actually imports, not everything installed on your machine.

What language is pipreqs written in?

Mainly Python. The stack also includes Python, pip.

How hard is pipreqs to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is pipreqs for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.