-
Notifications
You must be signed in to change notification settings - Fork 6
Working with pipenv
Pipfile is a new standard for defining requirements that are installed via pip. With a more robust definition format, Pipfile allows you to specify development and default requirements in one file, avoiding the need to have multiple requirements.txt files. In addition, it provides a way to lock ranges of requirements down to defined versions for the purpose of testing and deployment.
pipenv is a tool that wraps a number of Python packaging and dependency components: Pipfile, pip, and virtualenv.
It's so easy:
brew install pipenv
To install the requirements for a project, run pipenv install
. The installation process will first look for Pipfile.lock, then Pipfile, and finally fall back to converting requirements.txt to a Pipfile. Once a Pipfile has been created, pipenv will ignore requirements.txt.
pipenv takes care of the management of your virtual environment. You can issue individual commands that execute within the managed environment, or you can use a virtualenvwrapper-like experience with the pipenv shell.
To run an individual command:
pipenv run <command>
This will initialize the virtual environment, run the command, and deactivate the environment.
If you plan to be working in the environment for some time, you can load a shell within the context:
pipenv shell
This is essentially equivalent to virtualenvwrapper's workon
command. Once you are done working, you can close the shell with exit
or ^d
.