Skip to content Skip to sidebar Skip to footer

Pyenv Does Not Use Correct Python Version

using pyenv 2.0.3 when i'm in a folder with a python-version file, the python keeps using the system version which is 2.7.6. (not sure why it is 2.7.6 since i install 3.9.7 via bre

Solution 1:

The answer is to put the shims on the path

# pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/shims:$PATH"
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi
#if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi

Solution 2:

Assuming you're running MacOS and have installed pyenv via Homebrew, you'll need to do the following:

# Adjust the session-wide environment for your account.
echo 'eval "$(pyenv init --path)"' >> ~/.zprofile

# Enable autocompletion and all subcommands
echo 'eval "$(pyenv init -)"' >> ~/.zshrc

From pyenv installation docs:

MacOS note: If you installed Pyenv with Homebrew, you don't need to add the PYENV_ROOT= and PATH= lines. You also don't need to add commands into ~/.profile if your shell doesn't use it.


Post a Comment for "Pyenv Does Not Use Correct Python Version"