Add Python installed by Homebrew to pyenv version management

Add Python installed by Homebrew to pyenv version management

  1. Give the version a soft link to pyenv

    cd ~/.pyenv/versions
    ln -sfv "$(brew --prefix [email protected])" 3.9
    
  2. 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
    
  3. 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
    
  4. 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 python3is actually the version of homebrew, and it pyenv globalis impossible to actually switch the version), you need:

brew unlink [email protected]
pyenv rehash

Then you try again pyenv globalto 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

Guess you like

Origin blog.csdn.net/u012419550/article/details/122333366