1. 程式人生 > >Mac下安裝home-brew

Mac下安裝home-brew

      最近在Mac上安裝python3,在網上找了下,基本上是需要先安裝homebrew,安裝brew並不是有多難,而是官方給的方法在天朝不太實用(用了fq也不管用),在網上找了很多資料,然而給的答案基本上都是官方給的命令列,作為在天朝的我,一行簡單的指令碼試了好幾次,都不能正常的安裝,後來嘗試用國內的映象地址,雖然也嘗試了好多次,最後終於有了結果,安裝成功了,在這裡記錄下來,方便後來者不用浪費那麼多時間來安裝這個並沒有太難的工具。

     還是給出官方的安裝方式,喜歡的小夥伴可以試試:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
用國內的映象安裝的過程如下:

1.將安裝brew的檔案下載到本地

cd ~ && curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
2.修改安裝檔案內的映象源(BREW_REPO和CORE_TAP_REPO
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
# This script installs to /usr/local only. To install elsewhere you can just
# untar https://github.com/Homebrew/brew/tarball/master anywhere you like or
# change the value of HOMEBREW_PREFIX.
HOMEBREW_PREFIX = "/usr/local".freeze
HOMEBREW_REPOSITORY = "/usr/local/Homebrew".freeze
HOMEBREW_CACHE = "#{ENV["HOME"]}/Library/Caches/Homebrew".freeze
HOMEBREW_OLD_CACHE = "/Library/Caches/Homebrew".freeze

#BREW_REPO = "https://github.com/Homebrew/brew".freeze
BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze

#CORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze
CORE_TAP_REPO = "git://mirrors.ustc.edu.cn/homebrew-core.git".freeze
3.執行安裝
/usr/bin/ruby ~/brew_install
4.新增執行路徑
sudo vim /etc/profile
新增/etc/local/bin到PATH
source /etc/profile
5.驗證是否安裝成功
brew doctor

如果未提示command not found,則表示安裝成功

6.安裝python3

brew install python3
整個安裝過程結束。