Search code examples
python-3.xpipenv

Is it possible to use pipenv in same shell (not subshell)?


I'm new to pipenv. I'm used to virtualenv, where I can source a script to "activate" the env in my current shell. Is there a way to use pipenv that way, rather than starting a subshell? I.e. source $(pipenv shell-env) or something like that? I'd like to have a linear shell history, not have to double-exit to exit the terminal window, etc. I'm using python 3.6 and 3.7 on Mac and Windows primarily.


Solution

  • On Linux or macOS:

    source "$(pipenv --venv)/bin/activate"
    

    On Windows (using bash; thanks @Nickolay):

    source "$(pipenv --venv)/Scripts/activate"