Environment variables#
pipenv
environment variables#
pipenv --envs
outputs options of the environment variables.
For more information, see Configuration With Environment Variables.
.env
file#
If an .env
file exists in your virtual environment, $ pipenv shell
and $ pipenv run
will automatically load it:
$ cat .env
USERNAME=veit
$ pipenv run python
Loading .env environment variables...
…
>>> import os
>>> os.environ["USERNAME"]
'veit'
The credentials of the version management, can also be specified in the
Pipfile
, for example:
[[source]]
url = "https://$USERNAME:${PASSWORD}@ce.cusy.io/api/v4/projects/$PROJECT_ID/packages/pypi/simple"
verify_ssl = true
name = "gitlab"
Note
pipenv
hashes the pipfile
before determining the environment
variables, and the environment variables from the pipfile.lock
are
also replaced so that no credentials need to be stored in the version
management.
You can also save the .env
file outside your virtual environment. You
then only have to specify the path to this file in PIPENV_DOTENV_LOCATION
:
$ PIPENV_DOTENV_LOCATION=/PATH/TO/.env pipenv shell
You can also prevent pipenv
from using an existing .env
file with:
$ PIPENV_DONT_LOAD_ENV=1 pipenv shell