是否可以在同一个 shell(不是 subshel​​l)中使用 pipenv?

Gar*_*ryO 4 python-3.x pipenv

我是 pipenv 的新手。我已经习惯了 virtualenv,我可以在其中找到一个脚本来“激活”当前 shell 中的 env。有没有办法以这种方式使用 pipenv,而不是启动子shell?即source $(pipenv shell-env)或类似的东西?我想要一个线性的 shell 历史,不必双重退出来退出终端窗口等。我主要在 Mac 和 Windows 上使用 python 3.6 和 3.7。

cod*_*joe 5

在 Linux 或 macOS 上:

source "$(pipenv --venv)/bin/activate"
Run Code Online (Sandbox Code Playgroud)

在 Windows 上(使用 bash;感谢 @Nickolay):

source "$(pipenv --venv)/Scripts/activate"
Run Code Online (Sandbox Code Playgroud)