Add Python installed by Homebrew to pyenv version management
-
Give the version a soft link to pyenv
cd ~/.pyenv/versions ln -sfv "$(brew --prefix [email protected])" 3.9
-
include (the meaning is unknown and an error will be reported)
cd "$(brew --prefix [email protected])" ln -sfv Frameworks/Python.framework/Versions/3.9/include/python3.9 include include -> Frameworks/Python.framework/Versions/3.9/include/python3.9
-
Continue to give soft links to executable files
cd "$(brew --prefix [email protected])/bin" ln -sfv idle3 idle ln -sfv pip3 pip ln -sfv python3 python ln -sfv wheel3 wheel
-
pyenv reindex
pyenv rehash pyenv versions
You can see that there is already a version installed by homebrew. ready to use:
pyenv global 3.9
⚠️ If homebrew’s Python occupies the system (pyenv shows that it is using the system’s own system, but it which python3
is actually the version of homebrew, and it pyenv global
is impossible to actually switch the version), you need:
brew unlink [email protected]
pyenv rehash
Then you try again pyenv global
to actually change the global Python version.
reference
Stackoverflow 30499795: How can I make homebrew’s python and pyenv live together?
César Román: how-to-add-python-installed-via-homebrew-to-pyenv-versions