pyenv does not change python version on mac

拟墨画扇 提交于 2020-08-26 05:12:23

问题


I installed pyenv on mac and have used the following commands to install the required python version:

pyenv install 3.8.0
pyenv global 3.8.0

I am using zsh and my zshrc file contains the following:

if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi

When I check the python version, I can still see the old system version i.e. 2.7.15 responded by the command:

python -V

Any thoughts on what I might be doing wrong?

I have tried bash as well. I did not see any pyenv references in my bashrc file.


回答1:


Does it work if you restart your shell?

$ exec "$SHELL"

If yes then the problem is that zshenv is loaded too soon, you can add the following to .zprofile or .zshrc

if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi


来源:https://stackoverflow.com/questions/59097786/pyenv-does-not-change-python-version-on-mac

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