macOS升级Python3、PostgreSQL备忘录

1. 升级PostgreSQL

最近PostgreSQL更新到了10,于是将原来的9.6进行升级。
brew upgrade postgresql

2. 升级Python3

电脑中的Python版本为3.6.1,于是也尝试升级到最新的3.6.3。
brew upgrade python3

3. 在命令行中使用python3

升级Python后,原先的在命令行中使用Python3.6的命令python3失效,需要修改配置。

3.1. 打开.bash_profile文件

终端输入:
open ~/.bash_profile

3.2. 编辑bash_profile文件内容

PATH="/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH

#添加别名
Alias python3="/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/bin/python3.6"

3.3. 重新读取.bash_profile文件

终端输入:
source .bash_profile

4. 替换brew源

官方源下载速度实在太慢,可以替换成中科大或清华的镜像:

4.1. 中科大镜像

替换brew.git,终端输入:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

替换homebrew-core.git,终端输入:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

4.2. 清华镜像:

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

替换Homebrew-bottles:
open ~/.bash_profile
加入:

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles

保存
source .bash_profile

4.3. 还原官方源:

重置brew.git:
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

重置homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • macOS软件包管理器官网 安装 卸载 常用命令 brew help 查看帮助brew install 安装软...
    chad_it阅读 6,457评论 0 0
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,461评论 19 139
  • cocoapods安装过3次都蜜汁失败 在第七次终于成功 下列附上过程 有耐心的朋友可以试试的我的步骤和方法 ps...
    _Dam0n阅读 7,269评论 0 1
  • 转载来之原作者Elsewhere** http://col.dog/2015/11/22/homebrew/ Ma...
    坚持编程_lyz阅读 32,639评论 1 30
  • 一天,一只鸟儿飞落在井沿歇歇脚。一只坐在井里的青蛙与她攀谈起来。 “你从哪里来呀?” “我从遥远的地方来,我在天空...
    早安5点55阅读 3,833评论 0 0