pipenv commands code example

Example 1: pipenv

pip install pipenv # install pipenv
pipenv install # create venv
pipenv shell # active shell (for running commands)
pipenv install --dev # install to dev
pipenv uninstall --all # uninstall all dependencies
pipenv --venv # the venv location

Example 2: pipenv cheat sheet

# install
$ pip install pipenv

$ mkdir pipenv-test
$ cd pipenv-test

# Create a new project using Python 3
$ pipenv --three

# Output virtualenv information
$ pipenv --venv

# activate venv
$ pipenv shell

# check Python interpreter
$ which python
# or
$ pipenv --py

# install packages
$ pipenv install requests
# install a dev dependency
$ pipenv install --dev pytest 

# show dependency graph
$ pipenv graph

# security check
$ pipenv check

# delete Pipfile.lock for test
$ rm -f Pipfile.lock
# generate lock file again
$ pipenv lock

# create requirements.txt
$ pipenv lock -r ./requirements.txt

# uninstall everything
$ pipenv uninstall --all

# all gone
$ pipenv graph

# install all denpendencies, including the dev
# if following command is run without a venv,
# a venv will be created automatically.
$ pipenv install -d

# exit from venv
$ exit
# remove venv
$ pipenv --rm

Example 3: pipenv installs

pipenv install Django==3.1.2
pipenv install psycopg2-binary
pipenv install django-crispy-forms

Example 4: how to install pipenv

pipenv --python <version> install django==<version>
pipenv shell

django-admin startproject <name> .