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

There might be a bug for users installing tensorboard via anaconda #36

Open
hehaodele opened this issue May 4, 2017 · 6 comments
Open

Comments

@hehaodele
Copy link

I am using Anaconda as my python environment. To install tensorboard, I simply followed the instruction

pip install tensorboard

However when I run

$ tensorboard --logdir=path/to/logs

I get

  File "/home/haohe/anaconda2/bin/tensorboard", line 161, in <module>
    Main()
  File "/home/haohe/anaconda2/bin/tensorboard", line 111, in Main
    module_space = FindModuleSpace()
  File "/home/haohe/anaconda2/bin/tensorboard", line 92, in FindModuleSpace
    sys.argv[0])

Then I come to stackoverflow, find very useful information on (http://stackoverflow.com/questions/42600499/tensorboard-cannot-find-runfiles-directory-error/43174814)

By the recommandation there, I run

 find /home/haohe/anaconda2/ -name '*runfiles*'

which returns,

/home/haohe/anaconda2/lib/python2.7/site-packages/tensorboard/tensorboard.runfiles

Then I come to the /home/haohe/anaconda2/bin folder to check the tensorboard script, where I looked into the FindModuleSpace function and get

def FindModuleSpace():
  # Follow symlinks, looking for my module space
  stub_filename = os.path.abspath(sys.argv[0])
  while True:
    # Found it?
    module_space = stub_filename + '.runfiles'
    if os.path.isdir(module_space):
      break
    package_path = site.getsitepackages()
    # In case this instance is a string
    if not isinstance(package_path, list):
      package_path = [package_path]
    user_path = site.getusersitepackages()
    if not isinstance(user_path, list):
      user_path = [user_path]
    package_path.extend(user_path)
    for mod in package_path:
      module_space = mod + '/tensorboard/tensorboard' + '.runfiles'
    if os.path.isdir(module_space):
      return module_space

    runfiles_pattern = "(.*\.runfiles)/.*"
    if IsWindows():
      runfiles_pattern = "(.*\.runfiles)\\.*"
    matchobj = re.match(runfiles_pattern, os.path.abspath(sys.argv[0]))
    if matchobj:
      module_space = matchobj.group(1)
      break

    raise AssertionError('Cannot find .runfiles directory for %s' %
                         sys.argv[0])
  return module_space

I notice one weird thing is this piece of code,

    for mod in package_path:
      module_space = mod + '/tensorboard/tensorboard' + '.runfiles'
    if os.path.isdir(module_space):
      return module_space

It seems the only the last item in package_path will be checked. Thus I changed the code into

    #print package_path # to check the package_path
    for mod in package_path:
      module_space = mod + '/tensorboard/tensorboard' + '.runfiles'
      if os.path.isdir(module_space):
        return module_space

Then I make it work.

So I really would like to know, do I miss something when I install tensorboard or it might be something need to be fixed.

Thanks for your patience to read my experience.

@zihaolucky
Copy link
Member

You just need pip install tensorboard. The error here is the indent you've pointed out, sorry.

I would fix this bug later and rebuild the PyPI. Thank you.

@hehaodele
Copy link
Author

Right. Thanks.

@zihaolucky
Copy link
Member

Having some troubles in applying the patch in travis when updating the release for PyPI 😂 please give me some time to solve it.

@JONGGON
Copy link

JONGGON commented May 11, 2017

If 'tensorboard' does not work, you can change it.

1

@bermanmaxim
Copy link

I ran into this bug installing tensorboard through pip, python 2.7, linux: I get this around line 79 of the tensorboard script:

    for mod in package_path:
      module_space = mod + '/tensorboard/tensorboard' + '.runfiles'
    if os.path.isdir(module_space):
      return module_space

This should be fixed to the correct indentation:

    for mod in package_path:
      module_space = mod + '/tensorboard/tensorboard' + '.runfiles'
      if os.path.isdir(module_space):
        return module_space

This issue seems present in the .whl version 1.0.0a7; version 1.0.0a6 does not have this problem.

@leezu
Copy link

leezu commented Aug 14, 2017

This is not fixed in the current version on pypi but the master version in the github repository seems fine. Please update the version on pypi.

To fix the version that is currently on pypi (1.0.0a6) replace line 69
for mod in site.getsitepackages():
with
for mod in site.getsitepackages() + [site.getusersitepackages()]:

Otherwise the user site packages directory will not be checked and tensorboard will fail.

# 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

5 participants