DEV Community

Discussion on: My first impressions with pyenv

Collapse
 
baurt profile image
Tyler Baur

In order to have python use the current global pyenv version, you need to modify your PATH environment variable. See #2 under "Basic Github Checkout". Here's what it says to do the ZSH:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >>~/.zprofile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zprofile
echo 'eval "$(pyenv init --path)"' >> ~/.zprofile

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init --path)"' >> ~/.profile

echo 'eval "$(pyenv init -)"' >> ~/.zshrc

You could of course put that in the .zshrc instead of profile.
You need to make sure that the pyenv shims appear before the /usr/bin directory in the path. I'm not sure how the update-alternatives works with this, but I've never had an issue with pyenv with the shims at the front of the path. A call to

which python

should point to the pyenv shim, given you restarted the shell

Collapse
 
waylonwalker profile image
Waylon Walker

I put pyenv root right to the front of the $PATH and it was still going for system first. I ended up running update-alternatives --remove, and now pyenv has full control.