Pipenv is a package managing tool in Python, similar to using npm with Node.js.
Instead of manually managing a virtual environment and adding or removing packages for projects, pipenv can automatically do the entire process for us.
-
Instead of using
pip
orvirtualenv
seperately, we can usepipenv
which combines both. -
Instead of managing a
requirements.txt
file, pipenv uses aPipfile
andPipfile.lock
.
Here is what an example Pipfile looks like:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
flask = "*"
pandas = "*"
[dev-packages]
[requires]
python_version = "3.7.3"
We can easily see that this particular project uses Python version 3.7.3 and the flask and pandas libraries.
The overall development process will be easier us when using Python related tasks with pipenv.
Assuming you have pip
installed, you can download the tool through a simple pip install:
pip install pipenv
We can create a virtualenv automatically (or use the same one if it already exists) by using:
pipenv shell
If an environment exists already and all the dependencies are not installed, we can use:
pipenv install
This will install the required dependencies. We can also install all packages specified in a Pipfile.lock
:
pipenv sync
We can install packages like so:
pipenv install NAME_OF_PACKAGE
We can install dev dependenciees in a similar way:
pipenv install NAME_OF_PACKAGE --dev
We can remove a package like so:
pipenv uninstall NAME_OF_PACKAGE
We can easily check if our installed dependencies have security vulnerabilities:
pipenv check
If we need to remove the project virtualenv for any reasons we can use:
pipenv --rm