简体   繁体   English

在 `pipenv install` 之后使用 `pipenv shell` 会产生“UNKNOWN_VIRTUAL_ENVIRONMENT 的 Shell 已经激活。”

[英]Using `pipenv shell` after `pipenv install` yields "Shell for UNKNOWN_VIRTUAL_ENVIRONMENT already activated."

When I first install packages to a virtual environment with pipenv install package and secondly try to open a subshell to operate in that environment with pipenv shell i receive the following:当我第一次使用pipenv install package将软件包安装到虚拟环境,然后尝试打开一个子 shell 以使用pipenv shell在该环境中运行时,我收到以下信息:

"Shell for UNKNOWN_VIRTUAL_ENVIRONMENT already activated. No action taken to avoid nested environments." “UNKNOWN_VIRTUAL_ENVIRONMENT 的外壳已经激活。没有采取任何措施来避免嵌套环境。”

However, which python returns the file path of the system python, which indicated that actually the virtual environment is not activated.但是which python返回的是系统python的文件路径,说明实际上虚拟环境没有激活。

ctr+D and recalling pipenv shell finally opens a subshell within the virtual environment. ctr+D并调用pipenv shell最终在虚拟环境中打开一个子 shell。 Can someone explain me what's going on there?有人可以向我解释那里发生了什么吗? Honestly, I am severely conufused.老实说,我很困惑。

just cd to the folder that has your venv (.venv, Pipfile, Pipfile.lock) and run exit.只需 cd 到包含您的 venv(.venv、Pipfile、Pipfile.lock)的文件夹并运行退出。 it will exit the folder and now you can again cd to the same folder and use pipenv shell.它将退出文件夹,现在您可以再次 cd 到同一文件夹并使用 pipenv shell。 it will work它会起作用的

Exit the shell using exit and NOT deactivate .使用exit而不是deactivate退出 shell。 As explained here , " deactivate will leave pipenv in a confused state because you will still be in that spawned shell instance but not in an activated virtualenv."如此所述,“ deactivate将使 pipenv 处于混乱状态,因为您仍将处于生成的 shell 实例中,而不是处于激活的 virtualenv 中。”

Once you exit properly, you can navigate back to the directory and use pipenv shell正确退出后,您可以导航回目录并使用pipenv shell

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM