xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

How to install python3 on macOS All In One

How to install python3 on macOS All In One

$ python --version
# Python 2.7.15

$ python3 --version
# not found

Python 3.7.2

image

https://www.python.org/downloads/macos/

https://www.python.org/downloads/mac-osx/

https://www.python.org/downloads/release/python-372/

https://www.python.org/ftp/python/3.7.2/python-3.7.2-macosx10.9.pkg

py3 alias

zsh .zshrc

# > 覆盖写入配置文件
# >> 追加写入配置文件
$ echo "alias py=/usr/bin/python3" >> ~/.zshrc
$ echo "alias python=/usr/bin/python3" >> ~/.zshrc

.zshrc demo


# Python 3 ✅
# alias python=/usr/bin/python3
# alias py3='python3'

alias python=/usr/local/bin/python3
alias py3='python'

# which python3
# /usr/bin/python3
# which python 
# python: aliased to /usr/local/bin/python3
# source ~/.zshrc ✅

# export PATH="/usr/bin/python3:$PATH"
# export PATH="/usr/bin/:$PATH"
# $ cd /usr/bin/ && ls | grep "python" ✅
# $ cd /usr/bin/ && ls -al | grep "python" ✅

# Python3.11
# alias python=/usr/local/lib/python3.11
# alias py3='python'
# export PATH="/usr/local/lib/python3.11:$PATH"
# source ~/.zshrc ✅

# /usr/local/bin/python3
# /opt/local/bin/python3
# /sw/bin/python3

# /usr/local/bin/python3 --version
# Python 3.11.4
# /usr/local/bin/python3 --version
# Python 3.11.4

# .bash_profile
source ~/.bash_profile

# end zsh
# source ~/.zshrc

brew

homebrew

$ brew list

$ brew install python
# ???
$ brew install python3

https://brew.sh/

python@3.11

# ❌ 不存在 formula
$ brew install python@3.11.4

# ✅ 不好使 ❓
$ brew install python@3.11
$ brew list | grep python
# python@3.11

https://formulae.brew.sh/formula/python@3.11


Last login: Wed Jan 30 09:41:29 on console
➜  ~ python --version
Python 2.7.10
➜  ~ py3
zsh: command not found: py3
➜  ~ python3
zsh: command not found: python3


https://wsvincent.com/install-python3-mac/

Xcode

$ xcode-selec --install

$ sudo xcode-select -switch /Applications/Xcode.app

https://www.youtube.com/watch?v=NmB1AwF3G3k

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

refs

https://www.cnblogs.com/xgqfrms/p/17613043.html



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2019-01-30 14:11  xgqfrms  阅读(282)  评论(6编辑  收藏  举报