pyenvというのを使おうかと思ったけど、別にバージョンを切り替えて使う予定があるわけでもないし、rbenvでユーザ毎の管理で面倒だなと思ったのと、ネット検索で「別にpyenv使わなくてもいいんじゃね」みたいな記述もあったので、Homebrewで素直にインストール。
HomebrewもPython2なのかPython3なのか結構最近(今年の3月)ばたばたしてたようだけども、とりあえず
$ brew install python
と実行。↑これでPython3系がインストールされるらしいので。
$ brew install python
Updating Homebrew...
==> Auto-updated Homebrew!
中略
==> Installing dependencies for python: gdbm, readline, sqlite, xz
==> Installing python dependency: gdbm
==> Downloading
https://homebrew.bintray.com/bottles/gdbm-1.16.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gdbm-1.16.sierra.bottle.tar.gz
/usr/local/Cellar/gdbm/1.16: 19 files, 574.6KB
==> Installing python dependency: readline
==> Downloading
https://homebrew.bintray.com/bottles/readline-7.0.5.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring readline-7.0.5.sierra.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/readline/lib
CPPFLAGS: -I/usr/local/opt/readline/include
==> Summary
/usr/local/Cellar/readline/7.0.5: 46 files, 1.5MB
==> Installing python dependency: sqlite
==> Downloading
https://homebrew.bintray.com/bottles/sqlite-3.24.0.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring sqlite-3.24.0.sierra.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS provides an older sqlite3.
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/sqlite/lib
CPPFLAGS: -I/usr/local/opt/sqlite/include
For pkg-config to find this software you may need to set:
PKG_CONFIG_PATH: /usr/local/opt/sqlite/lib/pkgconfig
==> Summary
/usr/local/Cellar/sqlite/3.24.0: 11 files, 3.5MB
==> Installing python dependency: xz
==> Downloading
https://homebrew.bintray.com/bottles/xz-5.2.4.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring xz-5.2.4.sierra.bottle.tar.gz
/usr/local/Cellar/xz/5.2.4: 92 files, 1MB
==> Installing python
==> Downloading
https://homebrew.bintray.com/bottles/python-3.7.0.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring python-3.7.0.sierra.bottle.tar.gz
==> /usr/local/Cellar/python/3.7.0/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/3.7.0/bin --install-lib=/usr/local/lib/python3.7/site-pa
==> /usr/local/Cellar/python/3.7.0/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/3.7.0/bin --install-lib=/usr/local/lib/python3.7/site-pa
==> /usr/local/Cellar/python/3.7.0/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/3.7.0/bin --install-lib=/usr/local/lib/python3.7/site-pa
==> 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
Pip, setuptools, and wheel have been installed. To update them run
pip3 install --upgrade pip setuptools wheel
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.0: 4,788 files, 102.2MB
$
で完了。
実行は python3 とやる必要があるようで。
$ which python
/usr/bin/python
$ which python3
/usr/local/bin/python3
$ python --version
Python 2.7.10
$ python3 --version
Python 3.7.0
$
ログインしてコメントを確認・投稿する