pipenv : how to force virtualenv directory?

There is an undocumented feature of pipenv, it could locate virtualenv path from VIRTUAL_ENV environment variable, but you need to create virtualenv manually:

virtualenv /home/user/myapp_venv
VIRTUAL_ENV=/home/user/myapp_venv pipenv install

Apart from using a custom location, you can also install the virtualenv in your project's directory. Just add the following line in your .bashrc/.zshrc file:

export PIPENV_VENV_IN_PROJECT=1

Just wanted to let others know that there is another approach available too.

Should you keep the virtualenv inside or outside the project's directory is an opinionated question afterall.

Tags:

Python

Pip

Pipenv