2

This feels like such a simple question, but I can't find any reference in the pip documentation and the only question that seemed relevant mentions a flag that has apparently been deprecated since version 1.5 (version 8.1 is current at the time of this writing).

How do I "pretend" to install a package or list of packages using pip, without actually installing them? I have two separate use cases for this:

  • I need to see what packages out of a long (~70 line) requirements.txt are missing, without actually installing them; seeing what requirements are already satisfied without installing the missing requirements would satisfy this for me.
  • Finding the dependencies for a package that I have not yet installed on my computer, without using something like Portage or Aptitude.
Community
  • 1
  • 1
A. Wilcox
  • 1,782
  • 2
  • 12
  • 18

3 Answers3

2

There is also the pretty useful pip-tools package that provides a pip-sync tool which you can execute in a "dry run" mode against your requirements file(s):

$ mkvirtualenv test_so
New python executable in test_so/bin/python
Installing setuptools, pip, wheel...done.
...
(test_so) $ pip install pip-tools
...
Installing collected packages: six, click, first, pip-tools
(test_so) $ echo "Django==1.6.11" > requirements.txt
(test_so) $ pip-sync --dry-run requirements.txt 
Would install:
  Django==1.6.11

Also, here is a partially relevant thread: Check if requirements are up to date.

Roland Weber
  • 1,865
  • 2
  • 17
  • 27
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
0

Pip (v.23.2.1) has the --dry-run option. From the documentation:

Don’t actually install anything, just print what would be. Can be used in combination with --ignore-installed to ‘resolve’ the requirements.

You can it use it as

pip install poetry --dry-run

This will print normal output without actually installing anything.

rredondo
  • 503
  • 1
  • 10
  • 19
-4

Per the pip documentation, the proper way to generate the requirements.txt file is via pip freeze > requirements.txt. Hopefully this is what you wanted.

Elizafox
  • 1,316
  • 1
  • 8
  • 9