我一直在尝试按照这里的教程重新训练盗梦空间:https://www.tensorflow.org/tutorials/image_retraining。当我运行这个命令时,我得到了这个错误"No module named backports“
bazel-bin/tensorflow/examples/image_retraining/retrain --image_dir ~/marine_animal_species1这是完整的回溯:
Traceback (most recent call last):
File "/home/karthik/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/examples/image_retraining/retrain.py", line 91, in <module>
import tensorflow as tf
File "/home/karthik/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/karthik/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 64, in <module>
from tensorflow.python.framework.framework_lib import *
File "/home/karthik/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/framework/framework_lib.py", line 100, in <module>
from tensorflow.python.framework.subscribe import subscribe
File "/home/karthik/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/framework/subscribe.py", line 26, in <module>
from tensorflow.python.ops import variables
File "/home/karthik/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/ops/variables.py", line 26, in <module>
from tensorflow.python.ops import control_flow_ops
File "/home/karthik/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/ops/control_flow_ops.py", line 70, in <module>
from tensorflow.python.ops import tensor_array_ops
File "/home/karthik/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/ops/tensor_array_ops.py", line 33, in <module>
from tensorflow.python.util import tf_should_use
File "/home/karthik/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/util/tf_should_use.py", line 28, in <module>
from backports import weakref # pylint: disable=g-bad-import-order
ImportError: No module named backports我使用ubuntu 16.04。谢谢你的帮助。
发布于 2017-06-12 03:53:19
sudo pip install backports.weakref
sudo pip3 install backports.weakref为我解决了这个问题。
发布于 2017-06-12 02:59:56
从backports命名空间安装weakref模块。您可以从https://pypi.python.org/pypi/backports.weakref/1.0rc1获取轮子文件,并按如下方式安装下载的轮子:
sudo pip install backports.weakref-1.0rc1-py2-none-any.whl # python2
sudo pip3 install backports.weakref-1.0rc1-py3-none-any.whl # python3然后运行您的命令
bazel-bin/tensorflow/...这应该可以解决您的问题。
https://stackoverflow.com/questions/44485560
复制相似问题