TensorBoardトラブルシューティング

# 概要
virtualenv上の`pip3`で`~/.local`にTensorBoardをインストールすると何かと問題が起こったのでその解決方法のメモ

# 環境

```
(virtualenv) $ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"

(virtualenv) $ python3 --version
Python 3.5.2

(virtualenv) $ virtualenv --version
15.1.0

(virtualenv) $ pip3 list|grep tensor
tensorboard (1.0.0a6)
tensorflow (1.4.1)
tensorflow-tensorboard (0.4.0rc3)

(virtualenv) $ tensorboard --logdir=$HOME/.tensorboard/data/
TensorBoard 0.1.8 at http://localhost:6006 (Press CTRL+C to quit)
```

# Cannot find .runfiles directory for /home/user/.local/bin/tensorboard
#### エラー内容

```
$ tensorboard
Traceback (most recent call last):
  File "/home/user/.local/bin/tensorboard", line 152, in <module>
    Main()
  File "/home/user/.local/bin/tensorboard", line 102, in Main
    module_space = FindModuleSpace()
  File "/home/user/.local/bin/tensorboard", line 83, in FindModuleSpace
    sys.argv[0])
AssertionError: Cannot find .runfiles directory for /home/user/.local/bin/tensorboard
```

#### 解決策
tensorboardのpython3実行ファイルを一部書き換える.
(https://stackoverflow.com/questions/42600499/tensorboard-cannot-find-runfiles-directory-error)

```` /home/user/.local/bin/tensorboard
 61  def FindModuleSpace():                                                           
 62   # Follow symlinks, looking for my module space                                 
 63   stub_filename = os.path.abspath(sys.argv[0])                                   
 64   while True:                                                                    
 65     # Found it?                                                                  
 66     module_space = stub_filename + '.runfiles'                                   
 67     if os.path.isdir(module_space):                                              
 68       break                                                                      
-69     for mod in site.getsitepackages():
+69     for mod in site.getsitepackages() + [os.path.expanduser("~/.local/lib/python3.5/site-packages")]:
 70       module_space = mod + '/tensorboard/tensorboard' + '.runfiles'              
 71       if os.path.isdir(module_space):                                            
 72         return module_space                                                      
 73                                                                                  
 74     runfiles_pattern = "(.*\.runfiles)/.*"


````

#### 解説
`tensorboard/tebsorboard.runfiles`
というディレクトリが必要らしい.
このディレクトリはTensorBoardがインストールされているsite-packagesの中，今回の場合は
`~/.local/lib/python3.5/site-packages/tensorboard/tebsorboard.runfiles`
に存在したので，検索パスとして
`~/.local/lib/python3.5/site-packages`
をtensorboardの実行ファイルの69行目に追加した.

# PyBytes_AsStringAndSize
#### エラー内容

```
$ tensorboard
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.5/site-packages/tensorboard/tensorboard.runfiles/org_tensorflow/tensorflow/tensorboard/tensorboard.py", line 32, in <module>
    from tensorflow.python.summary import event_file_inspector as efi
  File "/home/user/.local/lib/python3.5/site-packages/tensorboard/tensorboard.runfiles/org_tensorflow/tensorflow/python/summary/event_file_inspector.py", line 122, in <module>
    from tensorflow.python.platform import gfile
  File "/home/user/.local/lib/python3.5/site-packages/tensorboard/tensorboard.runfiles/org_tensorflow/tensorflow/python/platform/gfile.py", line 22, in <module>
    from tensorflow.python.lib.io.file_io import copy as Copy
  File "/home/user/.local/lib/python3.5/site-packages/tensorboard/tensorboard.runfiles/org_tensorflow/tensorflow/python/lib/io/file_io.py", line 27, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/user/.local/lib/python3.5/site-packages/tensorboard/tensorboard.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/home/user/.local/lib/python3.5/site-packages/tensorboard/tensorboard.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: /home/user/.local/lib/python3.5/site-packages/tensorboard/tensorboard.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow.so: undefined symbol: PyBytes_AsStringAndSize
```

#### 解決策
tensorboard.tensorflow パッケージをインストール.
(https://github.com/dmlc/tensorboard/issues/42)

```
$ pip3 install tensorboard.tensorflow
```