pip freeze without dependencies of installed packages

I think the simply way to remove version is cut -d"=" -f1 after having run pip freeze.

pip3 freeze | cut -d"=" -f1 

There is no way to create "the most simplified requirements.txt" with pip - and I don't know if you would need it in this case.

It is good to have all packages in the requirements.txt, because you are sure about what dependencies versions work with your environment.

Think about paramiko getting updated, and breaking backwards compatibilities: you would have problems.


Now there is (disclaimer: I did it).

All you need is to install pip-chill from PyPI and run pip-chill from your Python environment.

If you are feeling adventurous and don't want to pin versions (or want to use pip-compile), you can use pip-chill --no-version and it'll give you the minimal requirements for your current environment.

https://github.com/rbanffy/pip-chill


pipdeptree is another option.

It produces full requirements.txt (with pipdeptree -f) like this:

jupyter==1.0.0
  ipykernel==5.4.3
    ipython==7.19.0
      backcall==0.2.0
      decorator==4.4.2
      jedi==0.17.2
        parso==0.7.1

This file serves two purposes:

  • Used as a traditional requirements.txt fed to pip install;
  • Used as a developer-friendly packages list (like the one created by pip-chill) simply with grep '^\w' requirements.txt.