On Mac OS, managing Python versions with homebrew is not trivial, almost impossible.
Here, I uninstall pre-installed python version and re-install a new specific version.
ls -l /usr/local/bin | grep /Library/Frameworks/Python.framework/Versions/3 | awk '{print "rm \47/usr/local/bin/" $9 "\47"}'
ls -d /Library/Frameworks/Python.framework/Versions/3.* 2> /dev/null | awk '{print "rm -rf \47" $0 "\47"}'
ls -d /Applications/Python\ 3.* 2> /dev/null | awk '{print "rm -rf \47" $0 "\47"}'
- Download a version from here: https://www.python.org/downloads/
- Install (note that you include openssl library path)
tar xzvf Python-[version].tgz
cd Python-[version]
./configure --prefix=/usr/local --enable-shared CPPFLAGS="-I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/openssl/lib"
make
sudo make install