UJP - macOS high Sierra上にpython3.6.5の環境を作る.

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

  • カテゴリ スキルチャージ の最新配信
  • RSS
  • RDF
  • ATOM

ブログ - macOS high Sierra上にpython3.6.5の環境を作る.

macOS high Sierra上にpython3.6.5の環境を作る.

カテゴリ : 
スキルチャージ » Python
ブロガー : 
ujpblog 2018/4/23 23:43
 これまでBashとcurlでどうにかしていたREST APIアクセスだけれど,限界を感じ始めたのでちょっとPythonを勉強してみようと考えた.それでまずは環境を整える.

現在の環境を確認

 macOS High Sierra 10.13.4 に最初から入っているPythonの場所とバージョンを調べる.
MBP2017:~ ujpadmin$ which python🆑
/usr/bin/python🈁
MBP2017:~ ujpadmin$
MBP2017:~ ujpadmin$ python --version🆑
Python 2.7.10🈁
MBP2017:~ ujpadmin$
 履いているのは2.x系.現在はPython 3系列が主軸?らしいし文法も違うというししがらみもないので,新しいバージョンを入れていくことにする.

pyenvをいれる

 最初に,Pythonの環境を整えるためにpyenvをインストール.パッケージなどを管理するツールと考えればよろし.
 brewで情報を確認.
MBP2017:~ ujpadmin$ brew info pyenv🆑
pyenv: stable 1.2.3 (bottled), HEAD
Python version management
https://github.com/pyenv/pyenv
Not installed🈁
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/pyenv.rb
==> Dependencies
Recommended: autoconf ✘, pkg-config ✘, openssl ✘, readline ✘
==> Options
--without-autoconf
	Build without autoconf support
--without-openssl
	Build without openssl support
--without-pkg-config
	Build without pkg-config support
--without-readline
	Build without readline support
--HEAD
	Install HEAD version
MBP2017:~ ujpadmin$
 pythonに限らず開発環境を整えてないので,不足しているもの多数...インストールする.
MBP2017:~ ujpadmin$ brew install pyenv🆑
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
r

==> Installing dependencies for pyenv: autoconf, pkg-config, openssl, readline
==> Installing pyenv dependency: autoconf
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.high_sierra.bottle.4.tar.gz
######################################################################## 100.0%
==> Pouring autoconf-2.69.high_sierra.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: 71 files, 3.0MB
==> Installing pyenv dependency: pkg-config
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.2.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pkg-config-0.29.2.high_sierra.bottle.tar.gz
🍺  /usr/local/Cellar/pkg-config/0.29.2: 11 files, 627.2KB
==> Installing pyenv dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2o_1.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2o_1.high_sierra.bottle.tar.gz
==> 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,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2o_1: 1,791 files, 12.3MB
==> Installing pyenv dependency: readline
==> Downloading https://homebrew.bintray.com/bottles/readline-7.0.3_1.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring readline-7.0.3_1.high_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.3_1: 46 files, 1.5MB
==> Installing pyenv
==> Downloading https://homebrew.bintray.com/bottles/pyenv-1.2.3.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pyenv-1.2.3.high_sierra.bottle.tar.gz
🍺  /usr/local/Cellar/pyenv/1.2.3: 597 files, 2.4MB
MBP2017:~ ujpadmin$
 OpenSSLに関する部分が何かしなければいけないようだけれど,それは次回以降として...

pyenvをいれる

 インストールしたpyenvの場所とバージョンを確認.
MBP2017:~ ujpadmin$ which pyenv🆑
/usr/local/bin/pyenv
MBP2017:~ ujpadmin$
MBP2017:~ ujpadmin$ pyenv -v🆑
pyenv 1.2.3
 無事インストールできた模様.

ディストリビューションはanaconda 

 Continuum Analyticsという会社が,Python本体にデータ分析系のライブラリなどをいい感じに揃えたパッケージを用意していて,それがAnacondaという名前のディストリビューションとなっており,人気なので,深く考えずにそれにあやかってみる.
 pyenvコマンドを使って,現在利用できる最新のanacondaのリストを取り出す.
MBP2017:~ ujpadmin$ pyenv install --list|grep anaconda|sort|tail🆑
  anaconda3-4.0.0
  anaconda3-4.1.0
  anaconda3-4.1.1
  anaconda3-4.2.0
  anaconda3-4.3.0
  anaconda3-4.3.1
  anaconda3-4.4.0
  anaconda3-5.0.0
  anaconda3-5.0.1
  anaconda3-5.1.0 🈁
MBP2017:~ ujpadmin$
 今日は全部最新で行くのでanaconda3-5.1.0をインストール.ちょっと時間がかかるので別の記事とします.

トラックバック


広告スペース
Google