pythonmacospython-install

Why is Python Installation in "Library" directory macOS?


I'm on a new Mac and installing Python. I believe I reinstalled my Python using Homebrew. The path, however, is unusual to me, and I'm wondering why it is located here:

/Library/Frameworks/Python.framework/Versions/3.9/bin/python3

I'm used to Python being somewhere like this, instead (which is also is):

/Users/user.name/Library/Python/3.9/bin

What is different about the first installation? Are there any special considerations if my Python is located here?


Solution

  • /Library/Frameworks/Python.framework/Versions/3.x/bin/python3 is the Python distribution shipped with macOS.

    It's usually a good practice to create your own Python environment for your projects instead of using the default Python installation (consider reading about pyenv).

    If you want to use your Homebrew installation, run brew info python to find your Python installation path, then append the parent directory's path to your PATH variable by editing ~/.zshrc (assuming you're using zsh, the default shell).

    $ brew info python
    ....
    Python has been installed as
      /opt/homebrew/bin/python3
    ...
    
    # inside ~/.zshrc
    ...
    export PATH="/opt/homebrew/bin:$PATH"
    ....