LoginSignup
0
4

More than 5 years have passed since last update.

Python3.6でKeras/Tensorflow環境構築

Last updated at Posted at 2017-10-24

実行環境(開始時点)

  • macOS Sierra 10.12.5
  • Python 2.7.10

やりたいこと

  • Keras/Tensorflowの環境を作る
    • KerasはTensorflowやtheanoと親和性が高いとのことなので、楽しそうと思ってやってみた
    • 途中で気づいたけど、2017/10/24時点でtheanoはpython3.6に非対応...
  • virtualenvを使ってpythonの仮想環境を作成→OS直轄のpython環境をピュアな状態に保つ

やったこと

  • homebrewのインストール

    • /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • python 3.6.3のインストール

    • brew install python3
      • 3.x系のどれがインストールされるかはhomebrewに上がっているバージョンに依存
      • pip3も同時にインストールされる
  • virtualenvのインストール

    • pip3 install virtualenv
      • pip3を指定しないとpython3.x系でvirtualenvが使えない
      • OSが使っているpythonのpipを使ってしまい、後々大混乱
  • 仮想環境の構築

    • virtualenv -p python3 py3
      • python3を使った「py3」というpythonの仮想環境を作成
  • 仮想環境の起動

    • source py3/bin/activate
  • Kerasのインストール

    • sudo pip3 install keras
  • TensorFlowのインストール

  • virtualenv用のmatplotlibの設定

    • 次の作業(Keras/Tensorflowのサンプルコード実行)でエラーが発生したため、このサイトに記載の対処を実施
      • ~/.matplotlib の中に matplotlibrc という名前のファイルを作成する
      • ~/.matplotlib/matplotlibrc に以下の行を追加する
~/.matplotlib/matplotlibrc
backend: TkAgg

表示されたエラー

  • RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are Working with Matplotlib in a virtual enviroment see 'Working with Matplotlib in Virtual environments' in the Matplotlib FAQ
    • 備忘録として残す
    • virtualenv使いのみなさんも同じ経験をしている模様
0
4
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
0
4