pipenv: Wrong Python inside of 'pipenv shell'

Inside of the pipenv shell subshell, I expected python to point to .venv/bin/python, but:

$ pipenv --version
pipenv, version 3.3.2

$ pipenv shell
Launching subshell in virtual environment. Type 'exit' or 'Ctrl+D' to return.

$ which python
/Users/Browning/.pyenv/shims/python

$ which -a python
/Users/Browning/.pyenv/shims/python
/Users/Browning/.local/share/virtualenvs/virtualboombox/bin/python
/Users/Browning/.pyenv/versions/3.6.0/bin/python
/Users/Browning/.pyenv/shims/python
/usr/local/bin/python
/usr/bin/python

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (14 by maintainers)

Most upvoted comments

Or maybe you should move pyenv init into .bash_profile instead (I am not sure what is zsh’s equivalent). profile is for login shells, and only evaluated once; rc is for non-login shells. pipenv shell launches non-login shells.

@uranusjr This is genius!!

I just tested, it works as expected and feels much cleaner than my version. For reference the zsh equivalent of .bash_profile is .zlogin: http://zsh.sourceforge.net/Intro/intro_3.html

Thanks for teaching me about login vs interactive shells. I’m switching to your version 👍

@jacebrowning yeah, this is a specific behaviour of pew. I’ve looked into a possible patch there, but don’t have anything that works with their idea of how virtualenvs work. The PIPENV_SHELL_COMPAT env variable is the way to go with pyenv.