Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

Issue when both python2 and python3 installed #30

Open
chaonan99 opened this issue Apr 6, 2017 · 6 comments
Open

Issue when both python2 and python3 installed #30

chaonan99 opened this issue Apr 6, 2017 · 6 comments

Comments

@chaonan99
Copy link
Contributor

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
@zihaolucky
Copy link
Member

Do you build from source or via PyPI?

@chaonan99
Copy link
Contributor Author

via PyPI

@zihaolucky
Copy link
Member

@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
Copy link
Member

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

@zihaolucky
Copy link
Member

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

@abhih1
Copy link

abhih1 commented Oct 31, 2017

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

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants