Pipenv Crash Course

Before I used virtualenv to create virtual env. The command set as below:

# install virtualenv
pip install virtualenv

# create new virtual env
virtualenv venv --python=python3.9 

# activate virtual env
source env/bin/activate

# dump current packages to .txt file
pip freeze > requirement.txt

# install packages from .txt file
pip install -r requirement.txt

# exit virtual env
exit

Another simple way to create python virtualenv:

pip3 install pipenv
pipenv --python 3.10

A Pipfile will be created as below:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.10"
python_full_version = "3.10.13"

Activate

pipenv shell

Install a package

pipenv install camelcase

Uninstall a package

pipenv uninstall camelcase
pipenv install openai=='0.28.1'

Re-install all packages from Pipfile

pipenv install

Check local packages

pipenv lock -r

Set lock file - before deployment

pipenv lock

Exit virtual env

exit

Remove the current virtual env

pipenv --rm