Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'tensorflow' has no attribute 'io' #39

Closed
5 of 8 tasks
initial-h opened this issue Apr 27, 2020 · 18 comments
Closed
5 of 8 tasks

AttributeError: module 'tensorflow' has no attribute 'io' #39

initial-h opened this issue Apr 27, 2020 · 18 comments
Labels
bug Something isn't working

Comments

@initial-h
Copy link

initial-h commented Apr 27, 2020

  • I have marked all applicable categories:

    • exception-raising bug
    • RL algorithm bug
    • documentation request (i.e. "X is missing from the documentation.")
    • new feature request
  • I have visited the source website, and in particular read the known issues

  • I have searched through the issue categories for duplicates

  • I have mentioned version numbers, operating system and environment, where applicable:

    import tianshou, torch, sys
    print(tianshou.__version__, torch.__version__, sys.version, sys.platform)

    python test/discrete/test_pg.py --seed 0 --render 0.03
    Traceback (most recent call last):
    File "test/discrete/test_pg.py", line 173, in
    test_pg()
    File "test/discrete/test_pg.py", line 144, in test_pg
    writer = SummaryWriter(log_path)
    File "/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/utils/tensorboard/writer.py", line 225, in init
    self._get_file_writer()
    File "/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/utils/tensorboard/writer.py", line 256, in _get_file_writer
    self.flush_secs, self.filename_suffix)
    File "/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/utils/tensorboard/writer.py", line 66, in init
    log_dir, max_queue, flush_secs, filename_suffix)
    File "/anaconda3/envs/pytorch/lib/python3.6/site-packages/tensorboard/summary/writer/event_file_writer.py", line 76, in init
    if not tf.io.gfile.exists(logdir):
    File "/anaconda3/envs/pytorch/lib/python3.6/site-packages/tensorboard/lazy.py", line 68, in getattr
    return getattr(load_once(self), attr_name)
    AttributeError: module 'tensorflow' has no attribute 'io'

@Trinkle23897
Copy link
Collaborator

What's your tensorflow and tensorboard version?

@initial-h
Copy link
Author

I just pip install git+https://github.com/thu-ml/tianshou.git@master directly. Need I install tf and tensorboard additionally for I didn't found these requirements in readme.

@Trinkle23897
Copy link
Collaborator

Trinkle23897 commented Apr 27, 2020

Tianshou has already added the tensorboard in the requirement, in https://github.com/thu-ml/tianshou/blob/master/setup.py#L53
Maybe something went wrong through the installation? Or have you already installed the tensorboard before installing tianshou? Upgrade them first.

@initial-h
Copy link
Author

No. I create a new env with conda, and pip install this repo.
conda create -n pytorch python==3.6.5
pip install git+https://github.com/thu-ml/tianshou.git@master
There may be something wrong among conda and pip

  writing requirements to tianshou.egg-info/requires.txt
  writing top-level names to tianshou.egg-info/top_level.txt
  writing manifest file 'tianshou.egg-info/SOURCES.txt'
  reading manifest file 'tianshou.egg-info/SOURCES.txt'
  writing manifest file 'tianshou.egg-info/SOURCES.txt'
  Copying tianshou.egg-info to build/bdist.linux-x86_64/wheel/tianshou-0.2.2-py3.6.egg-info
  running install_scripts
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-req-build-vr3fo7qw/setup.py", line 73, in <module>
      'pybullet',
    File "/anaconda3/envs/pytorch/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
      return distutils.core.setup(**attrs)
    File "/anaconda3/envs/pytorch/lib/python3.6/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/anaconda3/envs/pytorch/lib/python3.6/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/anaconda3/envs/pytorch/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/anaconda3/envs/pytorch/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 215, in run
      self.run_command('install')
    File "/anaconda3/envs/pytorch/lib/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/anaconda3/envs/pytorch/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/anaconda3/envs/pytorch/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
      return orig.install.run(self)
    File "/anaconda3/envs/pytorch/lib/python3.6/distutils/command/install.py", line 557, in run
      self.run_command(cmd_name)
    File "/anaconda3/envs/pytorch/lib/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/anaconda3/envs/pytorch/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/anaconda3/envs/pytorch/lib/python3.6/site-packages/setuptools/command/install_scripts.py", line 17, in run
      import setuptools.command.easy_install as ei
    File "/anaconda3/envs/pytorch/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 52, in <module>
      from setuptools.package_index import (
    File "/anaconda3/envs/pytorch/lib/python3.6/site-packages/setuptools/package_index.py", line 27, in <module>
      from setuptools.wheel import Wheel
  ModuleNotFoundError: No module named 'setuptools.wheel'
  ----------------------------------------
  ERROR: Failed building wheel for tianshou

@Trinkle23897
Copy link
Collaborator

Trinkle23897 commented Apr 27, 2020

Hmm...That's a problem. This morning I helped another person for installing tianshou on Anaconda. The following command works fine:

# create a new virtualenv and install pip, change the env name if you like
conda create -n myenv pip 
# activate the environment
conda activate myenv
# install tianshou
pip install tianshou

In short, please make sure the pip is installed in your created venv.

@initial-h
Copy link
Author

There is still the same problem...

@Trinkle23897
Copy link
Collaborator

Have you tried upgrading your conda, e.g., conda update conda?

@initial-h
Copy link
Author

Make no difference. It's the latest version already I think.

conda upgrade --all
Collecting package metadata (repodata.json): done
Solving environment: done
# All requested packages already installed.

@Trinkle23897
Copy link
Collaborator

No. I create a new env with conda, and pip install this repo.
conda create -n pytorch python==3.6.5
pip install git+https://github.com/thu-ml/tianshou.git@master
There may be something wrong among conda and pip

I test it but the second command pip is not in your "pytorch" venv. It will install some package outside your env.

@initial-h
Copy link
Author

conda will install pip, like you mentioned before.
conda create ...
source activate ...
pip install ...

@Trinkle23897
Copy link
Collaborator

Trinkle23897 commented Apr 27, 2020

So what's the output of "which pip" or "pip -V"?

@initial-h
Copy link
Author

you mean pip version? it's 20.0.2
pip 20.0.2 from /anaconda3/envs/pytorch/lib/python3.6/site-packages/pip (python 3.6)

@Trinkle23897
Copy link
Collaborator

Trinkle23897 commented Apr 27, 2020

Hmm...that's quite strange. BTW, I think "tensorflow" has no attribute "io" can be resolved by installing tensorflow manually. Though in the unittest it doesn't need to install tensorflow and still runs well.

In [11]: import tensorflow as tf

In [12]: tf.io
Out[12]: <module 'tensorflow._api.v1.io' from '/home/trinkle/.local/lib/python3.6/site-packages/tensorflow_core/_api/v1/io/__init__.py'>

@Trinkle23897
Copy link
Collaborator

You can also manually comment the lines of SummaryWriter in the test script :)

@initial-h
Copy link
Author

yeah, I pip install tensorflow manually and this problem has been solved. Thanks!

@Poojitha67
Copy link

yeah, I pip install tensorflow manually and this problem has been solved. Thanks!

I am facing the same issue. Can you pls help me resolve it?

@anggajulian14
Copy link

how to install tensorflow manually?

@Trinkle23897
Copy link
Collaborator

pip install tensorflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

4 participants