Make Pipenv create the virtualenv in the same folder

PythonPipenv

Python Problem Overview


I want Pipenv to make virtual environment in the same folder with my project (Django).

I searched and found the PIPENV_VENV_IN_PROJECT option but I don't know where and how to use this.

Python Solutions


Solution 1 - Python

PIPENV_VENV_IN_PROJECT is an environment variable, just set it (the value doesn't matter, but must not be empty). Make sure to export it so child processes of the shell can see it:

export PIPENV_VENV_IN_PROJECT="enabled"

This causes the virtualenv to be created in the .venv directory next to the Pipfile file. Use unset PIPENV_VENV_IN_PROJECT to remove the option again.

You may want to see if the direnv project can be useful here. It'll set environment variables for you, automatically, when you enter your project directory, provided you created a .envrc file in the project directory and enabled the directory with direnv. You then can add any such export commands to that file.

Solution 2 - Python

This maybe help someone else.. I find another easy way to solve this!

Just make empty folder inside your project and name it .venv

and pipenv will use this folder.

Solution 3 - Python

Try

PIPENV_VENV_IN_PROJECT=1 pipenv sync -d

Solution 4 - Python

For the fish shell, use:

set -Ux PIPENV_VENV_IN_PROJECT 1

Solution 5 - Python

For posterity's sake, if you find pipenv is not creating a virtual environment in the proper location, you may have an erroneous Pipfile somewhere, confusing the pipenv shell call - in which case I would delete it form path locations that are not explicitly linked to a repository.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDAMAR225View Question on Stackoverflow
Solution 1 - PythonMartijn PietersView Answer on Stackoverflow
Solution 2 - PythonDAMAR225View Answer on Stackoverflow
Solution 3 - PythonWeilaoView Answer on Stackoverflow
Solution 4 - PythonGringo SuaveView Answer on Stackoverflow
Solution 5 - PythonxxyjoelView Answer on Stackoverflow