Errors using brew to install python3 I'm trying to install python3 using brew on a 2008 MacBook (OSX Lion).

I have a few years using apt-get in Linux environments, but this is my first time trying to install something using brew.

Per the instructions at Get Your Mac Ready For Python Programming and Install Python 3 on Mac OS X and use virtualenv and virtualenvwrapper I entered:

brew install python3


This was after accidentally trying to install version 2.x of python using

brew install python


The python package installs fine, but when trying to install python3 I get

gcc-6 -Wno-unused-result -Wsign-compare -fno-common -dynamic -DNDEBUG -g  -O3 -Wall -Wstrict-prototypes -o FileSettings.o -c ./FileSettings.m
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:120:0,
             from ./FileSettings.h:9,
             from ./FileSettings.m:9:
/System/Library/Frameworks/Foundation.framework/Headers/NSTask.h:75:24: error: expected identifier or '(' before '^' token 
 @property (copy) void (^terminationHandler)(NSTask *) NS_AVAILABLE(10_7, NA);
                        ^
/System/Library/Frameworks/Foundation.framework/Headers/NSTask.h:78:1: error: expected identifier before 'end'
 @end
 ^
make[2]: *** [FileSettings.o] Error 1
make[1]: *** [install_PythonLauncher] Error 2
make: *** [frameworkinstallapps] Error 2

READ THIS: https://git.io/brew-troubleshooting
If reporting this issue please do so at (not Homebrew/brew):
  https://github.com/Homebrew/homebrew-core/issues

These open issues may also help:
python &amp; python3: fix sqlite3 on sierra https://github.com/Homebrew/homebrew-core/pull/3134
Warning: You are using OS X 10.7.


Per the errors I checked python &amp; python3: fix sqlite3 on sierra which seems to indicate the fault lies somewhere with sqlite3 however the link at python3 (v 3.5.1) failed to build on 10.7.5-x86_64 indicates its an issue with the compiler?

I'm not sure where to go next in the troubleshooting process.
I have no way to test it as I am not running 10.7 anymore, but the second issue you posted looks like the exact same error and a successful fix was in the comments:

brew install homebrew/dupes/apple-gcc42
brew install python3 --cc=gcc-4.2


This basically installs a compatible version of gcc and overrides compiler selection when installing python3.