My .bashrc has this:
enable-pyenv () {
# Load pyenv automatically by adding
# the following to your profile:
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
}
enable-pyenv
Which enables pyenv. In some situations, I want to (temporarily) disable pyenv. How can I do this?
If you want to use the python version from your system:
pyenv local system
https://github.com/pyenv/pyenv/blob/master/COMMANDS.md#pyenv-global
https://github.com/pyenv/pyenv/blob/master/COMMANDS.md#pyenv-local
Try playing around with some variants of:
env -i bash
env -i bash -l
env -i bash --norc
env -i bash --norc --noprofile
This does not come without side effects as env -i
nukes your whole session and thus afterwards a lot of convenience like $HOME
is gone with the bathwater, but so is pyenv
.
I'm not sure that this will get rid of all traces of pyenv, but editing your $PATH
environment variable to get rid of the pyenv- or shim-containing paths seems to deactivate pyenv. Eg,
export PATH=`echo $PATH | python -c "import sys, re; print(':'.join(x for x in sys.stdin.read().strip().split(':') if not 'pyenv' in x))"`
If you want to be able to re-enable it, just store your previous $PATH
so you can restore it later.
None of the posted answers worked for me but the following did:
$ echo "" > /home/myusername/.pyenv/version
Try pyenv deactivate
, to manually deactivate the virtual env.
Doc here: https://github.com/yyuu/pyenv-virtualenv