0

Is there any advantage of installing python 3 through homebrew vs through the installer from https://www.python.org/ or vice verse (except that the installer can give me the latest version)?

I try both and I can't find the difference.

---- update ----

I now gain some insights about this question.

  1. If I install python through the installer, the installer will modify PATH in .zprofile like following and create softlink /usr/local/bin/python3
    # Setting PATH for Python 3.8
    # The original version is saved in .zprofile.pysave
    PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
    export PATH
    
    # Setting PATH for Python 3.9
    # The original version is saved in .zprofile.pysave
    PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"
    export PATH

    ls -al /usr/local/bin/python3                             
    lrwxr-xr-x  1 root  wheel  69 11 20 11:18 /usr/local/bin/python3 -> 
    ../../../Library/Frameworks/Python.framework/Versions/3.9/bin/python3
  1. if I then install python thru brew, brew will complain. Sometimes I don't run brew install python directly but install some bottle, which installs python, e.g brew install httpie will install python, then brew complains
    ...
    ==> Caveats
    Python has been installed as
      /usr/local/bin/python3
    
    Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
    `python3`, `python3-config`, `pip3` etc., respectively, have been installed into
      /usr/local/opt/[email protected]/libexec/bin
  1. macOS preinstall python at /usr/bin/python & /usr/bin/python3 which remain unchanged. But since PATH is modified by the installer or brew (brew puts /usr/local/bin before /usr/bin) so preinstall python is shadowed.

  2. I do find brew has an "annoying" feature, when brew’s Python being installed as a dependency for a bottle and then I uninstall the bottle, the brew's Python remains. For example I installed httpie and uninstalled it. But to my surprise my system python is still the one installed by httpie. It took me quite sometimes to figure out that.

5
  • You may wish to consider MacPorts as an alternative to homebrew.
    – Seamus
    Oct 10, 2020 at 23:03
  • MacPorts is essentially the same thing as homebrew—a package manager. OP is asking for the difference between using a package manner and an installer, so this doesn't really help.
    – Nate
    Oct 11, 2020 at 1:23
  • @Nate: I've used homebrew (a few years ago), and I think a suggestion to use MacPorts instead of homebrew is quite helpful. :)
    – Seamus
    Oct 11, 2020 at 23:32
  • @Seamus I knew MacPorts but I have never tried it. So what is advantage of it over homebrew ? Oct 12, 2020 at 2:03
  • 1
    I find MacPorts far less confusing. Perhaps I'm biased, but in my mind MacPorts is a better version of apt (Debian's package manager), and apt is quite good. And I like beer as much as the next person, but all of the beer jargon homebrew uses never made sense to me. Wrt your question about any advantage of direct install vs a package manager, I think that advantage becomes clear once you get more than 2 or 3 packages installed: it's convenience. You have one interface to update all your packages instead of having to update them manually yourself.
    – Seamus
    Oct 12, 2020 at 4:37

3 Answers 3

3

I'd say it's entirely a matter of personal preference, as to whether you like to use HomeBrew or not.

There was a recent post about some problem with brew python, but it may be a local issue, or have been fixed. Python 3 'json' module is actually corrupted

1

For pure python it probably does not matter. All installations of extra modules are done using pip and you can deal with different versions of python with venv. The provision of venv and pipenv makes earlier answers less relevant as you now don't need a package manager, python now provides most of one.

The different installs differ when you need more complex native libraries.

I think pip makes some simplifying assumptions about the the compilation environment. The command line can be complex. There are several other issues that can be found on this site.

General package managers like MacPorts, Homebrew and Fink are built mainly to compile C libraries. If you use them rather than pip to install complex libraries like scipy then someone else has done all the complex work for you and it should be a simple install. You can still use pip for pure python so you are not limiting the choice of libraries you use.

However for the best overall management of python especially if it is your main development language I would look at Conda package manager. This is in essence a combination of a full package manger like Macports and Homebrew but originally designed for and written in python python and also provides similar functions to the python packaging of pip and venv. You can still use pip if needed. For an even easier way you can use Anaconda which is built on conda but the install includes many of the libraries you need for data science and also graphical front end to manage the packages.

7
  • Thanks for answering my answer. I never try MacPorts to install python. Since I use Homebrew I have not seen a case that I need to use MacPorts. May 7, 2021 at 9:21
  • @Qiulang Fair enough my answer is the general case and Macports and Fink are similar to Homebrew in this respect. Q&A here are more for future readers who have a similar problem rather than just the original questioner.
    – mmmmmm
    May 7, 2021 at 9:24
  • Hi I find you answered many questions about MacPorts. So according to your experience are there some cases that MacPorts do better than Homebrew ? May 7, 2021 at 9:56
  • @Qiulang That is a different question
    – mmmmmm
    May 7, 2021 at 9:57
  • I know but I was afraid if I asked a question like that it will be closed as opinion based. May 7, 2021 at 9:59
0

In the past 2 years, I have 3 different MacBooks and I did find a slightly advantage of using brew to install Python, which is when I want to clone all the development stuff to the new Macbooks, I can run brew list > brew_packages.txt in the old one and run brew install $(cat brew_packages.txt) in the new one.

1
  • 1
    Homebrew even has this builtin: Run brew bundle dump on the old system to create Brewfile, brew bundle install --file /path/to/Brewfile on the new to install.
    – nohillside
    May 9, 2023 at 5:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .