Python – How do I upgrade to python 3.6.4 on macOS?

How do I upgrade to python 3.6.4 on macOS?… here is a solution to the problem.

How do I upgrade to python 3.6.4 on macOS?

I’m trying to use python 3.6.4:

n155-p250:Desktop sahandzarrinkoub$ brew upgrade python3
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
bash-preexec        jenkins             presto              ttf2eot
cppcheck            khard               qpdf                txr
docker-gen          lz4                 scummvm             unixodbc
duplicity           mdp                 scummvm-tools       verilator
get-flash-videos    mycli               sslsplit
get_iplayer         ola                 tin
gobuster            ponyc               tokei

Error: python3 3.6.4_2 already installed
n155-p250:Desktop sahandzarrinkoub$ python3
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Although I already have it installed, I can’t use it by typing python3. How do I fix this? I want to remove 3.6.2 and map python3 to 3.6.4.

Solution

Since your python3 is not linked to homebrew, you should have homebrew force relink python3:

rm /usr/local/bin/python3
brew unlink python3; brew link --overwrite python3

The link for python3 on my machine is:

/usr/local/bin/python3 -> .. /Cellar/python3/3.6.4/bin/python3

Related Problems and Solutions