当前位置 博文首页 > mac下pip、conda、homebrew修改为清华镜像源的方法

    mac下pip、conda、homebrew修改为清华镜像源的方法

    作者:皮皮管理 时间:2021-09-18 18:27

    目录
    • 一、pip 修改为清华镜像源
    • 二、conda 修改为清华镜像源
    • 三、homebrew 修改为清华镜像源

    一、pip 修改为清华镜像源

    ① 打开终端,输入 cd ~/.pip/ ;如果没有 .pip 文件夹,就新建: mkdir .pip
    cd .pip
    vim pip.conf
    ④ 粘贴如下内容(清华镜像源),粘贴后,按 ESC 退出编辑模式,按 :wq! 进行保存并退出。你可以再打开终端依次输入②和③检查有没有粘贴成功。

    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    [install]
    trusted-host=pypi.tuna.tsinghua.edu.cn
    
    

    【备注】 .pip文件路径为 /Users/你的账户名/ .pip。按shift+command+ . 就能看到这些隐藏文件了,再按一次就能恢复隐藏。

    二、conda 修改为清华镜像源

    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    conda config --set show_channel_urls yes
    
    

    三、homebrew 修改为清华镜像源

    ① 打开终端,输入下面这一行,会自动生成文件名为 brew_install的文件(文件路径为 /Users/你的账户名/brew_install )

     curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
     
    

    ② 右键点击brew_install,打开方式选择 “文本编辑.app”。打开后如图所示,加 # 号注释掉原来的源,再把下面这一行复制粘贴进去即可,保存后关闭文件。

    BREW_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git".freeze
    
    

    在这里插入图片描述

    ③ 终端输入 /usr/bin/ruby brew_install 耐心等待(也要等很久)
    ④ 终端输入下面的内容即可完成。(提示:会自动安装 git 工具,等待即可)

    cd "$(brew --repo)"
    git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
    
    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
    git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
    
    brew update
    
    jsjbwy
    下一篇:没有了