Mac 下 安装Python3

本文详细介绍了如何在Mac系统中安装Python3,包括使用Homebrew查找、安装Python3的过程,以及安装后的验证方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

因为Mac系统自带Python2.7 所以我们开发要重新装Python3

直接运行下面就好

luohaotiandeMacBook-Pro:~ luohaotian$ which python
/usr/bin/python
luohaotiandeMacBook-Pro:~ luohaotian$ cd /usr/local/bin/
luohaotiandeMacBook-Pro:bin luohaotian$ ls
brew        lz4     perlthanks  ptardiff    svnrdump
cnpm        lz4c        piconv      ptargrep    svnserve
corelist    lz4cat      pl2pm       shasum      svnsync
cpan        node        pod2html    splain      svnversion
enc2xs      npm     pod2man     svn     unlz4
encguess    npx     pod2text    svnadmin    vue
h2ph        perl        pod2usage   svnbench    vue-init
h2xs        perl5.30.0  podchecker  svndumpfilter   vue-list
instmodsh   perlbug     podselect   svnfsfs     webpack
json_pp     perldoc     prove       svnlook     xsubpp
libnetcfg   perlivp     ptar        svnmucc     zipdetails
luohaotiandeMacBook-Pro:bin luohaotian$ python -V
Python 2.7.10
luohaotiandeMacBook-Pro:bin luohaotian$ brew search python3
==> Formulae
boost-python3              python3                    python@3
luohaotiandeMacBook-Pro:bin luohaotian$ brew install python3
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
jdupes                                   mk-configure

==> Installing dependencies for python: gdbm and xz
==> Installing python dependency: gdbm
==> Downloading https://homebrew.bintray.com/bottles/gdbm-1.18.1.mojave.bottle.1
######################################################################## 100.0%
==> Pouring gdbm-1.18.1.mojave.bottle.1.tar.gz
?  /usr/local/Cellar/gdbm/1.18.1: 20 files, 586.8KB
==> Installing python dependency: xz
==> Downloading https://homebrew.bintray.com/bottles/xz-5.2.4.mojave.bottle.tar.
==> Downloading from https://akamai.bintray.com/01/010667293df282c8bceede3bcd369
######################################################################## 100.0%
==> Pouring xz-5.2.4.mojave.bottle.tar.gz
?  /usr/local/Cellar/xz/5.2.4: 92 files, 1MB
==> Installing python
==> Downloading https://homebrew.bintray.com/bottles/python-3.7.3.mojave.bottle.
==> Downloading from https://akamai.bintray.com/25/25e0099852136c4ef1efd221247d0
######################################################################## 100.0%
==> Pouring python-3.7.3.mojave.bottle.tar.gz
==> /usr/local/Cellar/python/3.7.3/bin/python3 -s setup.py --no-user-cfg install
==> /usr/local/Cellar/python/3.7.3/bin/python3 -s setup.py --no-user-cfg install
==> /usr/local/Cellar/python/3.7.3/bin/python3 -s setup.py --no-user-cfg install
==> Caveats
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run
  brew install python@2

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> Summary
?  /usr/local/Cellar/python/3.7.3: 3,863 files, 59.8MB
==> Caveats
==> python
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run
  brew install python@2

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
luohaotiandeMacBook-Pro:bin luohaotian$ brew info python3
python: stable 3.7.3 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.7.3 (3,863 files, 59.8MB) *
  Poured from bottle on 2019-06-04 at 18:24:52
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb
==> Dependencies
Build: pkg-config ✘
Required: gdbm ✔, openssl ✔, readline ✔, sqlite ✔, xz ✔
==> Options
--HEAD
    Install HEAD version
==> Caveats
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run
  brew install python@2

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> Analytics
install: 378,873 (30 days), 1,357,511 (90 days), 4,253,975 (365 days)
install_on_request: 181,954 (30 days), 660,530 (90 days), 2,431,795 (365 days)
build_error: 0 (30 days)
luohaotiandeMacBook-Pro:bin luohaotian$ 

转载于:https://www.cnblogs.com/adrien/p/10975362.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值