Home > Net >  How to set PIPENV_IGNORE_VIRTUALENVS=1?
How to set PIPENV_IGNORE_VIRTUALENVS=1?

Time:10-26

While trying to create a venv for a django project while beeing in the projects dir using pipenv, I noticed that after installing django with pipenv (pipenv install django), pipenv sent a message:

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. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Creating a Pipfile for this project...
Installing django...
[=   ]  Installing django...[packages]...
Installation Succeeded
Pipfile.lock not found, creating...
Locking [packages] dependencies...
           Building requirements...
Resolving dependencies...
Success!
Locking [dev-packages] dependencies...
Updated Pipfile.lock (99c4b9ec1b8891ff787677276760beb6d6d4919c55660da1c713682156a6086c)!
Installing dependencies from Pipfile.lock (a6086c)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

After this I ran the command (pipenv --venv) and got this message:

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. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
C:\Users\User7G\OneDrive\Desktop\My code\My VSCode Projects\VSCode

I knew from the start that all my vscode projects were using the VSCode venv, however for this project I needed to make a new venv becaushe of the requirements of installing and running django.

How do I set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to create a new venv? Where and how do I need to set PIPENV_IGNORE_VIRTUALENVS=1?

CodePudding user response:

Your question is equivalent to, how do I set persistent environment variables on Windows? Or, how do I set environment variables to be used by VS Code specifically? I encourage you to use those searches to learn more.

In this case, I believe you can do

setx PIPENV_IGNORE_VIRTUALENVS 1

For VS Code Python, there is also the setting

"python.envFile": "${workspaceFolder}/.env"

So you can create/append to an .env file in your workspace root directory that contains

PIPENV_IGNORE_VIRTUALENVS=1
  • Related