pip icon indicating copy to clipboard operation
pip copied to clipboard

Adding option to exclude ==<version number> from requirements.txt created by pip freeze

Open tommasosansone91 opened this issue 4 years ago • 5 comments

What's the problem this feature will solve?

Many users report problems tied with the number of version of some packages when running a project where python libraries to installed are defined in requirements.txt.

One of the best solutions is to delete ==<version number> from requirements.txt, which is generally created via pip freeze > requirements.txt.

Describe the solution you'd like

So, would it be possible to implement the action of generating requirements.txt without including version number for each python library?

e.g. (trying to follow the syntax stated in pip freeze docs )

-nv, --no-version

    exclude version numbers of packages from output.

pip freeze -nv > requirements.txt

requirements.txt:

asn1crypto
asyncpg
bcrypt
cffi
cryptography
gevent
greenlet
parallel-ssh
paramiko
Pillow
pkg-resources
psycopg2-binary
pycparser
PyNaCl
reportlab
six
ssh2-python
tornado



Alternative Solutions

right now a workaround is to use pip chill --no-version, but this option should rather be put into command pip freeze

Additional context

none

Code of Conduct

tommasosansone91 avatar Oct 07 '21 13:10 tommasosansone91

This can be achieved today with pip list --format=json | jq -r ".[].name".

If this had to become a native pip feature, I'd rather see it as a pip list format variant.

sbidoul avatar Oct 12 '21 11:10 sbidoul

I would prefer something like this: pip install -r requirements.txt --ignore-version

That way requirements.txt can still hold all the information needed, but the user need not use it

JustTheCoolest avatar Apr 12 '25 06:04 JustTheCoolest

I am a bit disappointed when sensible feature requests keep being dismissed by "This can be achieved today..." and then some pipe into a Unix utility with some obscure syntax. It would be nice it these posters would acknowledge a) that the vast majority of Python development is on the Windows platform and b) that users of Python language are not typically shell script geeks. It is not only a waste of time to google the right magic pipe every time I need to solve a common problem like this, it is also a potential security risk to copy shell script code I do not fully understand and run it on my computer.

thobitz avatar Jun 06 '25 06:06 thobitz

Going off because a volunteer suggested a workaround 4 years later instead of trying to solve it is exactly the kind of energy that's preventing the stuff happening

In particular if its a usage that not part of what saud volunteers use

RonnyPfannschmidt avatar Jun 06 '25 06:06 RonnyPfannschmidt

Here's a platform neutral Python script to list all installed packages:

from importlib.metadata import distributions

for dist in distributions():
    print(dist.metadata['Name'])

@thobitz please be more thoughtful about the language you use and the assumptions you make when interacting here. Phrases like “shell script geeks” and “waste of time to google the right magic pipe” are both loaded and dismissive to people who are providing working solutions for many people.

As mentioned, pip is currently an all volunteer project, we choose to spend our time on it to help users out, and sometimes a quick workaround has a far higher cost effectiveness for time spent with users helped, than adding more complexity to pip that requires more code to maintain indefinitely.

This doesn’t need any further discussion. Let’s stay on topic of providing solutions to users.

notatallshaw avatar Jun 06 '25 13:06 notatallshaw