Home > other >  Pip install a package in a way that it gets not listed in requirements.txt
Pip install a package in a way that it gets not listed in requirements.txt

Time:11-11

Is it possible to install a pip package in a way so that it gets not listed when doing pip freeze > requirements.txt?

I am thinkging of an equivalent to: poetry add --dev which adds (installs) a package as a development dependency, but it does not appear in dependency list.

Is there a way in pip to do something similar?

CodePudding user response:

What you want is pipenv. There are ways of making RStudio work with pipenv (link to an article). This allows both complete package control, python version specification for a project as well as virtualenv, all in one. Otherwise, you'd have to maintain your requirements.txt file manually, and further down the line use a constraints.txt file, also.

Think of pipenv files as what yarn.lock files (JS) vs package.json file some extra sweet features.

You can use pipenv to generate a requirements.txt file by doing:

pipenv lock -r > requirements.txt

While you can add/install packages in development mode by:

pipenv install --dev <mypackage>
  • Related