dmlc / tensorboard

Standalone TensorBoard for visualizing in deep learning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue when both python2 and python3 installed

chaonan99 opened this issue · comments

I've encountered a issue when both python2 and 3 are installed on the same machine but tensorboard is installed via python3. (Typically python2 is called via python and python3 via python3 in this situation.) But FindPythonBinary function won't realize that now. Currently I just hacked into the script and force it to search python3, but I believe there is a better way.

Error message below:

Traceback (most recent call last):
  File "/home/chenhaonan/.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/chenhaonan/.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/chenhaonan/.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/chenhaonan/.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/chenhaonan/.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/chenhaonan/.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/chenhaonan/.local/lib/python3.5/site-packages/tensorboard/tensorboard.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow.so: und

Do you build from source or via PyPI?

via PyPI

@chaonan99 Thanks for the feedback.

If we build from source, the .configure might set up properly.

PYTHON_BINARY = '/Users/zihao.zzh/anaconda2/envs/tensorboard/bin/python'
if IsWindows() and not PYTHON_BINARY.endswith('.exe'):
  PYTHON_BINARY = PYTHON_BINARY + '.exe'

When in PyPI, as we use machines from Travis, the PYTHON_BINARY is from that machine. So I handle this issue in tensorboard-distro https://github.com/zihaolucky/tensorboard-distro/blob/master/tools/travis_wheel/python-binary-and-runfiles.patch#L17-L23

       'Bazel does not support execution of Python interpreters via labels yet')
   elif PYTHON_BINARY.startswith('/'):
     # Case 2: Absolute path.
-    return PYTHON_BINARY
+    if os.path.exists(PYTHON_BINARY):
+      # file exists
+      return PYTHON_BINARY
+    else:
+      # not exist, have to search. often occurs in travis-built wheel.
+      return SearchPath('python')
   elif '/' in PYTHON_BINARY:
     # Case 3: Path is relative to current working directory.
     return os.path.join(os.getcwd(), PYTHON_BINARY)

I guess the return SearchPath('python') might do the trick, could you have a try? Just hack the compiled tensorboard from PyPI.

@chaonan99 I've fixed the tensorboard-binary.patch where we bring a bug in #29, also the PyPI has been update to 1.0.0a7 for #29 and #32

I would make a new PR for this issue later.

@chaonan99 @zihaolucky Is this solved? I'm having the same trouble.I have python 2.7 and 3.6, and I installed tensorflow using pip3. Can you please give simple instructions to deal with this? Thanks!