Chris Martin
Chris Martin

Reputation: 30756

How do you `pip freeze` without installing the packages?

The only way I know how to freeze the requirements of a Python project is rather arduous:

  1. Create a fresh virtualenv
  2. Install all of the requirements (a potentially IO and CPU intensive process that may also require external dependencies for libraries whose install involves compiling C)
  3. Run pip freeze

How do you go directly from a requirements.txt to a frozen requirements file, without all of the expensive side effects?


For example, if requirements.txt looks like this:

abc

where abc is a project that depends on another project called xyz, and I run pip [something] > requirements_frozen.txt, then requirements_frozen.txt might look like:

abc==0.1
xyz==2.3

Upvotes: 5

Views: 1365

Answers (2)

Chris Martin
Chris Martin

Reputation: 30756

The pip-tools library includes a command called pip-compile which does this.

Upvotes: 1

Mridang Agarwalla
Mridang Agarwalla

Reputation: 45108

Use pipreqs. It does just that - "and sometimes you just need to create requirements.txt for a new project without installing modules."

https://github.com/bndr/pipreqs

Upvotes: 0

Related Questions