August 11, 2019 ยท 2 min read
Pipenv is both a package and virtual python environment management tool. It's build on top of virtualenv and Pip - and it's super easy to use.
First, create your project folder. If you already have a project using Pip and requirements.txt you can still follow these steps. To create a new project folder run:
mkdir my-appcd my-app
Now initialise the Pipenv environment by running:
pipenv install
This will create two files, Pipefile and Pipefile.lock
Pipfile - specifies package requirements of your Python application
Pipfile.lock - states which specific version of the package should be used
To install a package e.g Flask run:
pipenv install flask
To install a package for development e.g pytest run:
pipenv install --dev pytest
To run your project, you need to activate your Pipenv environment shell with:
pipenv shell
Then, to exit the shell run:
exit
A cleaner way to run commands using your environment is using run, for example, to run the command 'flask run' you can use :
pipenv run flask run
And that's it! You now know enough to get started with pipenv.