question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generate requirements.txt from Pipfile.lock

See original GitHub issue

How to generate requirements.txt file from existing Pipfile.lock without locking? When I run pipenv lock -r it ignores existing Pipfile.lock and does locking process again.

There is a workaround for this:

$ pipenv sync
$ pipenv run pip freeze

In my particular situation I’m building docker image and using requirements.txt in Dockerfile. I’d like to avoid creating virtual environment on the host machine just to be able to create requirements.txt.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:35
  • Comments:32 (4 by maintainers)

github_iconTop GitHub Comments

126reactions
anuj9196commented, Jul 16, 2019

you can run

pipenv run pip freeze > requirements.txt
95reactions
Zebradilcommented, Jul 16, 2019

you can run

pipenv run pip freeze > requirements.txt

That’s what I mentioned as a workaround in the first post.

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

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

Blog post jq tool

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python HOW: Create requirements.txt Using pipenv
A step-by-step guide to create your first requirements.txt file that lists all the ... This creates a Pipfile.lock file (or updates an existing...
Read more >
pipenv lock [> requirements.txt] - Fig.io
Name, Description. --dev-only, Generate a requirements file with only the development requirements. --header, Add header to generated requirements.
Read more >
How to freeze a requirement with pipenv? - Stack Overflow
Pipenv do natively implement freezing requirements.txt. It is as simple as: pipenv lock -r > requirements.txt.
Read more >
pipenv-to-requirements - PyPI
Generate requirements [-dev].txt from Pipfile using pipenv. ... Pipfile is to be maintained by the package's developer while Pipfile.lock represent a clear ...
Read more >
Setting up a Python development environment with pipenv
Generate your own pipfile.lock · Put the requirements.txt file in your project directory · Run pipenv lock · Run pipenv install --ignore-pipfile - ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found