Basic Pipenv workflow

Basic pipenv commands for quick recall:

Pipenv commands needed on a daily basis

  • To enter virtual env made by pipenv, use: pipenv shell.

  • To exit virtual env, use exit command. Don’t use deactivate.

  • Use pipenv instead of pip to install/uninstall packages:

    • You can install a package as project dependency for deployment/execution (under packages section of Pipfile using): pipenv install flask
    • You can install a package as project dependency for development (under dev-packages section of Pipfile using): pipenv install --dev pytest
    • To uninstall run this command (which also removes references to python package both from Pipfile and Pipfile.lock): pipenv uninstall django
  • The Pipfile.lock is intended to specify, based on the packages present in Pipfile, which specific version of those should be used, avoiding the risks of automatically upgrading packages that depend upon each other and breaking your project dependency tree. This command will lookup your virtual environment folder to generate the Pipfile.lock file for you automatically, based on the currently installed versions: pipenv lock

  • Delete a virtual env created by pipenv: pipenv --rm

  • To see location of virtual env added by pipenv: pipenv --venv

Install Pipenv on Mac

brew install pipenv

Migrate requirements.txt to Pipenv

  1. Navigate to your project directory and initialize a Pipfile: pipenv install

    • This should automatically find requirements.txt file in pwd and convert it into Pipfile. In case it doesn’t, you can run: pipenv install -r requirements.txt
  2. If certain dependencies are only required during development (e.g., pytest or black), you can reinstall them under dev-packages section of Pipenv using: pipenv install <package_name> --dev

  3. Once everything is working fine, you can safely move the old requirements.txt file outside the folder, but still keep it as a backup somewhere.

Setup existing project with existing Pipenv on new laptop with fresh virtualenv

  • Install pipenv, then cd to the project directory which contains Pipenv file.
  • This command will create a new virtual environment as well as install dependencies listed in Pipfile.lock: pipenv install

Related post

My current LLM workflow

Prompt management and versioning https://github.com/hypersigilhq/hypersigil/ https://www.prompthub.us/ https://github.com/pezzolabs/pezzo https://promptguild.ai/home https://github.com/agenta-ai/agenta https://docs.promptlayer.com/why-promptlayer/how-it-works AI workflow…