homebrewでpython (anaconda) をインストールする

  • homebrewをアップデート
$ brew update && brew upgrade
Updated 1 tap (homebrew/core).
==> New Formulae
hesiod          osrm-backend    questdb         svgcleaner      typescript    
libsquish       piknik          rmlint          terragrunt      yarn          
nvc             pyinvoke        sql-translator  ttyd          
==> Updated Formulae
ace                        gprof2dot                  plantuml                 
android-ndk                grib-api                   ponyc                    
ansible-cmdb               gstreamermm                postgis                  
antigen                    gtkextra                   progress                 
apache-flink               gupnp-av                   prometheus               
aqbanking                  gx                         python                   
artifactory                gx-go                      python3                  
asciinema2gif              i2p                        qca                      
avro-c                     ice                        qjackctl                 
aws-sdk-cpp                imagemagick                qscintilla2              
awscli                     jemalloc                   qt5                      
azure-cli                  jenkins                    remctl                   
bash-git-prompt            jsonpp                     ripgrep                  
bear                       kerl                       rswift                   
bgpq3                      khard                      rtv                      
binwalk                    knot                       s-search                 
bitrise                    kubernetes-cli             shadowsocks-libev        
bsdconv                    ldns                       shyaml                   
cake                       libgee                     sonarqube                
cern-ndiff                 libiscsi                   sqldiff                  
certbot                    libnfs                     sqlite                   
chaiscript                 libnotify                  sqlite-analyzer          
cjdns                      libtorrent-rasterbar       ssdb                     
commandbox                 libxmp                     svtplay-dl               
conan                      liquibase                  tailor                   
consul-backinator          macvim                     tippecanoe               
cppcheck                   mailhog                    titan-server             
cromwell                   mariadb                    tmux                     
dbhash                     meson                      tomcat                   
digdag                     metabase                   vala                     
djview4                    metaproxy                  vapoursynth              
doctl                      micro                      vdirsyncer               
elixir                     mongoose                   verilator                
evince                     monkeysphere               vim                      
fabio                      mutt                       vultr                    
file-roller                mysql                      wine                     
geckodriver                node                       winetricks               
ghex                       node-build                 x265                     
git-credential-manager     offlineimap                xonsh                    
git-lfs                    open-babel                 yazpp                    
glib                       opencsg                    you-get                  
gnome-builder              oysttyer                   youtube-dl               
gnome-themes-standard      pazpar2                    zimg                     
gnuplot                    pcap_dnsproxy              zplug                    
gofabric8                  pgroonga                   zsh-navigation-tools     
==> Deleted Formulae
ezlupdate       pyside          pyside-tools    qwtpolar        shiboken 
  • pyenvをインストールして.bash_profileを設定
$ brew install pyenv
==> Installing dependencies for pyenv: autoconf, pkg-config, openssl, readline
==> Installing pyenv dependency: autoconf
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.el_capitan.bottle.
######################################################################## 100.0%
==> Pouring autoconf-2.69.el_capitan.bottle.4.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/autoconf
==> Summary
🍺  /usr/local/Cellar/autoconf/2.69: 70 files, 3.0M
==> Installing pyenv dependency: pkg-config
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.1_2.el_capitan.b
######################################################################## 100.0%
==> Pouring pkg-config-0.29.1_2.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/pkg-config/0.29.1_2: 10 files, 627.4K
==> Installing pyenv dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2j.el_capitan.bottle
######################################################################## 100.0%
==> Pouring openssl-1.0.2j.el_capitan.bottle.tar.gz
==> Using the sandbox
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
    PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2j: 1,695 files, 12M
==> Installing pyenv dependency: readline
==> Downloading https://homebrew.bintray.com/bottles/readline-7.0.el_capitan.bottle.t
######################################################################## 100.0%
==> Pouring readline-7.0.el_capitan.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

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.


Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/readline/lib
    CPPFLAGS: -I/usr/local/opt/readline/include

==> Summary
🍺  /usr/local/Cellar/readline/7.0: 45 files, 2M
==> Installing pyenv
==> Downloading https://github.com/yyuu/pyenv/archive/v1.0.2.tar.gz
==> Downloading from https://codeload.github.com/yyuu/pyenv/tar.gz/v1.0.2
######################################################################## 100.0%
==> Caveats
To use Homebrew's directories rather than ~/.pyenv add to your profile:
  export PYENV_ROOT=/usr/local/var/pyenv

To enable shims and autocompletion add to your profile:
  if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
==> Summary
🍺  /usr/local/Cellar/pyenv/1.0.2_1: 522 files, 2.2M, built in 6 seconds

$ echo 'export PYENV_ROOT="${HOME}/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="${PYENV_ROOT}/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile

$ exec $SHELL -l
  • pyenvでanacondaをインストールする
$ pyenv install -l | grep anaconda3
  anaconda3-2.0.0
  anaconda3-2.0.1
  anaconda3-2.1.0
  anaconda3-2.2.0
  anaconda3-2.3.0
  anaconda3-2.4.0
  anaconda3-2.4.1
  anaconda3-2.5.0
  anaconda3-4.0.0
  anaconda3-4.1.0
  anaconda3-4.1.1

$ pyenv install anaconda3-4.1.1
Downloading Anaconda3-4.1.1-MacOSX-x86_64.sh...
-> https://repo.continuum.io/archive/Anaconda3-4.1.1-MacOSX-x86_64.sh
Installing Anaconda3-4.1.1-MacOSX-x86_64...