【问题标题】:How to set PIPENV_IGNORE_VIRTUALENVS=1?如何设置 PIPENV_IGNORE_VIRTUALENVS=1?
【发布时间】:2022-10-25 03:04:51
【问题描述】:

在使用 pipenv 在项目目录中尝试为 django 项目创建 venv 时,我注意到在使用 pipenv (pipenv install django) 安装 django 后,pipenv 发送了一条消息:

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.

在此之后,我运行命令 (pipenv --venv) 并收到以下消息:

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

我从一开始就知道我所有的 vscode 项目都在使用 VSCode venv,但是对于这个项目,我需要制作一个新的 venv,因为需要安装和运行 django。

如何设置 PIPENV_IGNORE_VIRTUALENVS=1 以强制 pipenv 创建新的 venv? 我需要在哪里以及如何设置 PIPENV_IGNORE_VIRTUALENVS=1?

【问题讨论】:

    标签: python python-3.x django powershell pipenv


    【解决方案1】:

    您的问题相当于,如何在 Windows 上设置持久环境变量?或者,如何设置 VS Code 专门使用的环境变量?我鼓励您使用这些搜索来了解更多信息。

    在这种情况下,我相信你可以做到

    setx PIPENV_IGNORE_VIRTUALENVS 1
    

    对于 VS Code + Python,还有设置

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

    因此,您可以在工作区根目录中创建/附加到 .env 文件,其中包含

    PIPENV_IGNORE_VIRTUALENVS=1
    

    【讨论】:

      猜你喜欢
      • 2014-07-15
      • 1970-01-01
      • 1970-01-01
      • 2017-04-26
      • 2014-05-01
      • 2020-12-08
      • 2022-06-10
      • 2023-01-13
      • 1970-01-01
      相关资源
      最近更新 更多