Pipenv: Is there a way to disable / suppress pipenv's "Courtesy Notice" about virtual environments?

Created on 5 Jul 2018  路  7Comments  路  Source: pypa/pipenv

Each time I invoke pipenv I see:

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead.

Can this be globally suppressed?

Future Type good first issue help wanted

Most helpful comment

Does PIPENV_IGNORE_VIRTUALENVS=0 have any significance? If pipenv was told to not ignore virtual envs, then that should mean I want to use my existing virtual env, and the courtesy notice should be suppressed.

All 7 comments

No, there is not.

That said, maybe we can treat an empty PIPENV_IGNORE_VIRTUALENVS as the suppressor.

  • PIPENV_IGNORE_VIRTUALENVS absent鈥攕how the message.
  • PIPENV_IGNORE_VIRTUALENVS set to empty string鈥攕uppress the message, but use the environment.
  • PIPENV_IGNORE_VIRTUALENVS is not empty鈥攃reate a nested virtualenv.

Does PIPENV_IGNORE_VIRTUALENVS=0 have any significance? If pipenv was told to not ignore virtual envs, then that should mean I want to use my existing virtual env, and the courtesy notice should be suppressed.

We have an environment variable to suppress output but we don't use it much. We can add this to the refactor

My current workaround:

pipenv lock --requirements 2> >(grep -v "Courtesy Notice" >&2) > requirements.txt

@max-arnold You found a bug! lock -r should output to stdout (it does when you鈥檙e not in a virtualenv), but for some reason outputs to stderr when you are inside. You shouldn鈥檛 need more than pipenv lock --requirements > requirements.txt. We will fix that. Sorry for the annoyance.


Edit: After some testing, you should be able to run pipenv lock --requirements 2>/dev/null on Linux or Mac. No need for fancy grep-ing.

@uranusjr Fancy grep and redirections are used to filterCourtesy Notice while preserving stderr/stdout separation and exit codes.

Was this page helpful?
0 / 5 - 0 ratings