Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonekratz/d91af01ee5c84bbbaca633cf7b056da4 to your computer and use it in GitHub Desktop.
Save jasonekratz/d91af01ee5c84bbbaca633cf7b056da4 to your computer and use it in GitHub Desktop.
Set up Homebrew-installed Python to be used by Pyenv

Did this while installing Azure CLI on my Mac.

At install time this had a dependency on Python 3.10 that I tried to resolve using the version 3.10.11 that was installed via Pyenv. Could not get this to work so uninstalled 3.10.11 via Pyenv, did a pyenv rehash, and then installed 3.10.11 directly via Homebrew: brew install python@3.10

I then set up Pyenv to be able to use this new version via a variation of the instructions found here. This required some changes though because the symlinks weren't right in the example given because I wanted the specific version of Python installed via Homebrew. If I wanted python3 in my PATH without needing Pyenv the install would have been brew install python3 which likely would have meant the symlink setup below would have been different.

This is what I had to do.

  1. cd ~/.pyenv/versions
  2. ln -sfv "$(brew --prefix python@3.10)" 3.10.11
  3. pyenv rehash
  4. cd /opt/homebrew/Cellar/python@3.10/3.10.11
  5. ln -sfv ../Frameworks/Python.framework/Versions/3.10/bin/idle3.10 idle3
  6. ln -sfv ../Frameworks/Python.framework/Versions/3.10/bin/idle3.10 idle
  7. ln -sfv pip3.10 pip
  8. ln -sfv pip3.10 pip3
  9. ln -sfv ../Frameworks/Python.framework/Versions/3.10/bin/python3.10 python3
  10. ln -sfv ../Frameworks/Python.framework/Versions/3.10/bin/python3.10 python
  11. ln -sfv wheel3.10 wheel
  12. ln -sfv wheel3.10 wheel3
  13. ln -sfv ../Frameworks/Python.framework/Versions/3.10/bin/pydoc3.10 pydoc
  14. ln -sfv ../Frameworks/Python.framework/Versions/3.10/bin/pydoc3.10 pydoc3
  15. pyenv rehash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment