Starting out when I run $ which python3
I get:
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3
And in my .zprofile I have:
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH
So starting out, I have 3.8 installed and it works. Now, I need to create a setup that will allow me to install and use different versions of python for different projects.
So, I tried the following:
$ brew update
$ brew install pyenv
$ pyenv version
It printed out System
. So, it only sees the python 2.7 that comes with macos. Then I tried:
$ pyenv install 3.9.1
$ pyenv install 3.8.7
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi' >> ~/.zshrc
$ source ~/.zshrc
Now, at the end of my .zshrc
file I have:
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
But I still just get System
when I run $ pyenv version
. I know the different python versions are getting installed in ~/.pyenv/versions
directory. So, what else am I supposed to do to get it
to list all the versions and switch back and forth between them?
question from:
https://stackoverflow.com/questions/65913995/how-install-and-use-different-versions-of-pythons-on-macos-using-pyenv 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…