I want to keep my new computer organized and use pipenv, how can i change the default location of a virtual environment location to a folder in my documents, so when i run "pipenv shell" in a project folder it will put the location of the actual virtual env into the document instead of hiding it in folders/folders/folders...

I tried to look at the docs and I couldn't find a clear answer.

2

There are 2 best solutions below

0
chepner On

The location of the virtual environments can be controlled by setting the WORKON_HOME environment variable.

Pipenv automatically honors the WORKON_HOME environment variable, if it is set, so you can tell pipenv to store your virtual environments wherever you want, e.g.:

export WORKON_HOME=~/.venvs

It also supports @ch4rl1e97's recommendation:

In addition, you can also have Pipenv stick the virtualenv in project/.venv by setting the PIPENV_VENV_IN_PROJECT environment variable.

The value of the variable should be one of 1, true, yes, or on. (See https://pipenv.pypa.io/en/latest/configuration.html#configuration-with-environment-variables)

0
Alex Mkwizu On

I think you want to create a custom Virtual Environment Location for your virtual environments , for your case is in the native DOcuments folder ,

Pipenv always sticks to the WORKON_HOME environment variable , given it has been set , then you can dictate pipenv to store your virtual environments wherever you want.

nano ~/.bashrc

Add the following line on the file:

export WORKON_HOME=~/Documents/MyVirtualEnv/.venvs

Then type to activate it

source ~/.bashrc

NB: make sure you have the folder " MyVirtualEnv " , in your documents folder For more information check here : https://pipenv.pypa.io/en/latest/virtualenv.html