tensorboard icon indicating copy to clipboard operation
tensorboard copied to clipboard

Issue when both python2 and python3 installed

Open chaonan99 opened this issue 7 years ago • 6 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

chaonan99 avatar Apr 06 '17 11:04 chaonan99

Do you build from source or via PyPI?

zihaolucky avatar Apr 06 '17 12:04 zihaolucky

via PyPI

chaonan99 avatar Apr 06 '17 12:04 chaonan99

@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)

zihaolucky avatar Apr 06 '17 12:04 zihaolucky

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

zihaolucky avatar Apr 06 '17 12:04 zihaolucky

@chaonan99 I've fixed the tensorboard-binary.patch where we bring a bug in https://github.com/dmlc/tensorboard/pull/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.

zihaolucky avatar Apr 30 '17 14:04 zihaolucky

@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!

abhih1 avatar Oct 31 '17 19:10 abhih1