0

Note

If you’d like a requirements.txt output of the lockfile, run $ pipenv lock -r. This will include all hashes, however (which is great!). To get a requirements.txt without hashes, use $ pipenv run pip freeze.

According to the above pipenv notice, if you’d like a requirements.txt output of the lockfile, you should run $ pipenv lock -r. However, the -r options does not exist:

$ pipenv lock -r
Usage: pipenv lock [OPTIONS]
Try 'pipenv lock -h' for help.
$ pipenv lock -h
Usage: pipenv lock [OPTIONS]

Generates Pipfile.lock.

Options: --categories TEXT --dev-only Emit development dependencies only (overrides --dev) -d, --dev Generate both develop and default requirements [env var: PIPENV_DEV] --extra-pip-args TEXT --pre Allow pre-releases. --python TEXT Specify which version of Python virtualenv should use. --clear Clears caches (pipenv, pip). [env var: PIPENV_CLEAR] -q, --quiet Quiet mode. -v, --verbose Verbose mode. --pypi-mirror TEXT Specify a PyPI mirror. -h, --help Show this message and exit.

May I know the command to get the requirements.txt output of the pipenv lockfile?

muru
  • 207,228
Sun Bear
  • 3,014

2 Answers2

1

The website you have linked to is pipenv-fork.readthedocs.io/en/latest/basics.html. The official docs at https://pipenv.pypa.io/en/latest/pipfile.html#pipfile-lock-security-features says:

Generate requirements.txt output from lock file

$ pipenv requirements
muru
  • 207,228
0

Simply you can run

pipenv run pip freeze > requirements.txt

But it works only if you have your pipenv environment synchronized (all packages are installed). Extracting dependencies directly from Pipfile.lock is more convenient:

jq -r '.default
        | to_entries[]
        | .key + .value.version' \
    Pipfile.lock > requirements.txt

It's remarkable that you must have jq (or install it in case of absence) in your environment before this practice on extraction