It is difficult to access python.org from China mainland so it failed when I tried
brew install python. Shadowsocks provides socks proxy but Homebrew who invokes curl implicitly cannot leverage socks proxy directly.
Polipo is a http proxy and can use socks proxy as an internet connection way. Fortunately it is ok to install Polipo directly from China mainland.
brew install polipo polipo socksParentProxy=localhost:1080 export https_proxy=http://127.0.0.1:8123 export http_proxy=http://127.0.0.1:8123 brew install python