24

Over the weekends I have upgraded my Ubuntu to 20.04, and I tried creating virtualenvironment with python 3.8.2, and pip install requirements.txt. In requirement.txt, I am installing some code from private gitlab repositories.

Previously, if I do pip freeze, I was able to see all packages name and version (formatted as package_name == version.

However, if I do pip freeze, now I see something like this...

pkg1 @ file:///tmp/tmp44ir_jik
pkg2 @ file:///tmp/tmp5pijtzbq
...

(pkg1 and pkg2 are both from pip installing private git repo)

I would like to somehow display the version, but don't know how to.

I mean, pip list does show the version, but I am writing a script and would like to use pip freeze for it. How can I get pip freeze to show how it use to before (with the format as pkg_name==pkg_version)?

Thanks in advance.

X Æ A-Xiii
  • 576
  • 4
  • 14
Lowan
  • 277
  • 3
  • 9
  • 1
    I don't get it, why is `pip3 freeze > requirements_patrick_mds_clean.txt` produce unusable requirements.txt files? what's the point of that command if it then makes pkgs depend on local paths/versions? – Charlie Parker Jan 05 '23 at 17:50

2 Answers2

34

You can use pip list --format=freeze instead.

X Æ A-Xiii
  • 576
  • 4
  • 14
  • @ X Æ A-13 I see. Yes it now shows it in the format that I wanted. However, how do I change the format for **pip freeze directly**, rather than doing 'pip list' then changing format? – Lowan May 13 '20 at 03:06
  • 4
    I guess you'd have to downgrade with `pip install "pip<20.1"`. Or try and get the [PEP 610](https://www.python.org/dev/peps/pep-0610/) reverted. – X Æ A-Xiii May 13 '20 at 03:09
  • @X Æ A-13 Downgrading it worked! It's also nice to know that pip list has --format flag to get what I want too. Thank you! – Lowan May 13 '20 at 03:26
  • 2
    somehow i'm not surprised that elon's son is already answering questions on stackoverflow – billiam Feb 09 '22 at 00:29
  • 2
    I don't get it, why is `pip3 freeze > requirements_patrick_mds_clean.txt` produce unusable requirements.txt files? what's the point of that command if it then makes pkgs depend on local paths/versions? – Charlie Parker Jan 05 '23 at 17:50
8

I could not comment to answer the question by Iowan above; thus is redundant to the answer by X Æ A-13:

 pip list --format=freeze > requirements.txt
  • I don't get it, why is `pip3 freeze > requirements_patrick_mds_clean.txt` produce unusable requirements.txt files? what's the point of that command if it then makes pkgs depend on local paths/versions? – Charlie Parker Jan 05 '23 at 17:50