One-step Install+Save for Python Dependencies

One-step Install+Save for Python Dependencies

Pip install django psycopg2-binary. pip freeze. Either manually copy and paste the specific version numbers into requirements. txt (or do a cat requirements.

TL;DR:

Open up your .zshrc or .bashrc file and paste the following into the bottom:

# pip install and save to (and sort + dedupe) requirements.txt
    function pip-save {
        # loop through all listed requirements
        for var in "[email protected]"
        do
            # attempt to install it
            pip install $var

            # add it to the requirements.txt file
            pip freeze | grep -i "^$var=" >> requirements.txt
        done

        # sort requirements.txt and remove duplicates
        sort -u requirements.txt -o requirements.txt
    }

Now you can do: pip-save django psycopg2-binary and get an updated requirements.txt with a locked in version, and move on with what you actually set out to do.

Motivation

After almost a decade as Node.js developer, I’m back in Python land.

One immediate pet peeve when spinning up new services was how much more typing and copy/pasting I was doing to install dependencies.

Installing a JS dependency (e.g. express and mongoose):

  1. npm install --save express mongoose
  2. End of list. Move on with life.

programming flask python python3 django

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Guide to Python Programming Language

Guide to Python Programming Language

Python Django Tutorial | Django Course

🔥Intellipaat Django course: https://intellipaat.com/python-django-training/ 👉This Python Django tutorial will help you learn what is django web development &...

Basic GUI Calculator in Python - Python Programming 

Basic GUI Calculator in Python - Python Programming  - This article will take you through the entire process of developing a GUI calculator in Python. If you are reading this article, you…

Python Hello World Program - Create & Run Your First Python Program in PyCharm

Python Hello World Program - Your first step towards Python world. Learn how to create the Hello World Python program in PyCharm.

Python Programming Tutorials For Beginners

Python Programming Tutorials For Beginners