LoginSignup
17
15

More than 5 years have passed since last update.

Mac(El Captain)にpython3系インストール

Last updated at Posted at 2016-06-05

環境

OS X El Capitan(10.11.5)
HomeBrewインストール済み

pyenvインストール

デフォルトでpython2が入っているが、バージョン切り替えを管理したいのでpyenv(rubyでいうrbenv)をインストール

$ brew install pyenv

パスの設定

$ export PYENV_ROOT="$HOME/.pyenv"
$ export PATH="$PYENV_ROOT/bin:$PATH"
$ eval "$(pyenv init -)"

インストールできるpythonのバージョンを確認

$ pyenv install --list

pythonインストール

最新のpython3.5.1をインストール

$ pyenv install 3.5.1

エラー。。。

Downloading Python-3.5.1.tgz...
-> https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
Installing Python-3.5.1...

BUILD FAILED (OS X 10.11.5 using python-build 20160130)

Inspect or clean up the working tree at /var/folders/cc/yzctrdxs00s81p18dssxqhpw0000gn/T/python-build.20160605231006.7256
Results logged to /var/folders/cc/yzctrdxs00s81p18dssxqhpw0000gn/T/python-build.20160605231006.7256.log

Last 10 log lines:
  File "/private/var/folders/cc/yzctrdxs00s81p18dssxqhpw0000gn/T/python-build.20160605231006.7256/Python-3.5.1/Lib/ensurepip/__main__.py", line 4, in <module>
    ensurepip._main()
  File "/private/var/folders/cc/yzctrdxs00s81p18dssxqhpw0000gn/T/python-build.20160605231006.7256/Python-3.5.1/Lib/ensurepip/__init__.py", line 209, in _main
    default_pip=args.default_pip,
  File "/private/var/folders/cc/yzctrdxs00s81p18dssxqhpw0000gn/T/python-build.20160605231006.7256/Python-3.5.1/Lib/ensurepip/__init__.py", line 116, in bootstrap
    _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/private/var/folders/cc/yzctrdxs00s81p18dssxqhpw0000gn/T/python-build.20160605231006.7256/Python-3.5.1/Lib/ensurepip/__init__.py", line 40, in _run_pip
    import pip
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1

OSアップデートしていると、XCode command line toolsが必要だったらしい(https://github.com/yyuu/pyenv/wiki

$ xcode-select --install
xcode-select: note: install requested for command line developer tools

改めてpython3.5.1をインストール

$ pyenv install 3.5.1

バージョンを確認

$ pyenv versions
* system (set by /Users/32mashamasha/.pyenv/version)
  3.5.1

インストールできた( ´ ▽ ` )ノ

17
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
15