Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Pipenv create the virtualenv in the same folder

Tags:

python

pipenv

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.

like image 314
DAMAR225 Avatar asked Sep 27 '18 15:09

DAMAR225


People also ask

Where does Pipenv create virtualenv?

pipenv stores the packages inside your local machines shared directory called virtualenvs (~/. local/share/virtualenvs/<env-name> ). It ensures that you don't need to use pip and virtualenv separately.


3 Answers

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=1

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 allow. You then can add any such export commands to that file.

like image 80
Martijn Pieters Avatar answered Oct 19 '22 07:10

Martijn Pieters


This maybe helps someone else. I found another easy way to solve this!

Just make an empty folder inside your project and name it .venv and pipenv will use this folder.

like image 68
DAMAR225 Avatar answered Oct 19 '22 09:10

DAMAR225


Try

PIPENV_VENV_IN_PROJECT=1 pipenv sync -d
like image 5
Weilao Avatar answered Oct 19 '22 09:10

Weilao