mac 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,則表示安裝成功


轉自:https://blog.csdn.net/banche163/article/details/79250482

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章