ImportError: No module named 'tensorflow.tensorboard.tensorboard'

前端之家收集整理的这篇文章主要介绍了ImportError: No module named 'tensorflow.tensorboard.tensorboard'前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

系统:ubuntu14.04
通过anaconda(Python 3.6 version)安装的tensorflow,今天想使用tensorboard

(tensorflow) yang@yang-HP-Pavilion-g4-Notebook-PC:~/eclipse_workspace/tensorflow$ tensorboard --logdir=path/to/log-directory
Traceback (most recent call last):
  File "/home/yang/anaconda3/envs/tensorflow/bin/tensorboard",line 4,in <module>
    import tensorflow.tensorboard.tensorboard
ModuleNotFoundError: No module named 'tensorflow.tensorboard'

运行时候报错:import tensorflow.tensorboard.tensorboard
ModuleNotFoundError: No module named ‘tensorflow.tensorboard’

看半天,实在不明白,并且通过find命令查找tensorboard相关的文件

find /home/yang/anaconda3/ -name *tensorboard*

运行后得到的结果是

/home/yang/anaconda3/envs/tensorflow/bin/tensorboard
/home/yang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/tensorboard
/home/yang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/training/__pycache__/tensorboard_logging.cpython-36.pyc
/home/yang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/training/tensorboard_logging.py
/home/yang/anaconda3/pkgs/tensorflow-1.3.0-py36_0/bin/tensorboard
/home/yang/anaconda3/pkgs/tensorflow-1.3.0-py36_0/lib/python3.6/site-packages/tensorflow/contrib/tensorboard
/home/yang/anaconda3/pkgs/tensorflow-1.3.0-py36_0/lib/python3.6/site-packages/tensorflow/python/training/__pycache__/tensorboard_logging.cpython-36.pyc
/home/yang/anaconda3/pkgs/tensorflow-1.3.0-py36_0/lib/python3.6/site-packages/tensorflow/python/training/tensorboard_logging.py

发现的确没有tensorboard.py文件

于是更新tensorflow

yang@yang:~/osgi_workspace/tensorflow$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
yang@yang:~/osgi_workspace/tensorflow$ source activate tensorflow
(tensorflow) yang@yang:~/eclipse_workspace/tensorflow$ conda update tensorflow

然后会提示

The following packages will be SUPERSEDED by a higher-priority channel:

    tensorflow: 1.3.0-py36_0 conda-forge --> 1.2.1-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

Proceed ([y]/n)? 

输入y,更新成功之后,再使用find命令查找与tensorboard相关的文件,既可以发现tensorboard.py文件了。于是再次执行,tensorboard命令,就不会报错了。
因此,我遇到的ImportError: No module named ‘tensorflow.tensorboard.tensorboard’,是采用更新tensorflow的方法解决的。
备注:在更新时候,首先要激活tensorflow,注意命令提示符前面有(tensorflow)

参考文档:
anaconda换源:http://www.jb51.cc/article/p-zirmeoej-p.html

原文链接:https://www.f2er.com/ubuntu/351351.html

猜你在找的Ubuntu相关文章