Deactivate pyenv in current shell

人盡茶涼 提交于 2020-01-31 10:42:21

问题


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?


回答1:


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




回答2:


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.




回答3:


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.




回答4:


None of the posted answers worked for me but the following did:

$ echo "" > /home/myusername/.pyenv/version



回答5:


Try pyenv deactivate, to manually deactivate the virtual env.

Doc here: https://github.com/yyuu/pyenv-virtualenv



来源:https://stackoverflow.com/questions/39348806/deactivate-pyenv-in-current-shell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!