美文网首页
macOS升级Python3、PostgreSQL备忘录

macOS升级Python3、PostgreSQL备忘录

作者: Apri | 来源:发表于2017-10-31 21:50 被阅读81次

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升级Python3、PostgreSQL备忘录

      本文链接:https://www.haomeiwen.com/subject/xiyipxtx.html