Versioning的Tensorflow textsum错误

Tensorflow textsum error of Versioning

我正在尝试将训练文本文件转换为bin文件以训练tensorflow的textsum。但是我遇到了以下错误:

$ python textsum/data_convert_example.py --command text_to_binary --in_file data/tt.txt --out_file data/bin_data_train
Traceback (most recent call last):
  File "textsum/data_convert_example.py", line 12, in <module>
    import tensorflow as tf
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 104, in <module>
    from tensorflow.python.platform import test
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/test.py", line 57, in <module>
    import mock                # pylint: disable=g-import-not-at-top,unused-import
  File "/usr/local/lib/python2.7/dist-packages/mock/__init__.py", line 2, in <module>
    import mock.mock as _mock
  File "/usr/local/lib/python2.7/dist-packages/mock/mock.py", line 71, in <module>
    _v = VersionInfo('mock').semantic_version()
  File "/usr/local/lib/python2.7/dist-packages/pbr/version.py", line 461, in semantic_version
    self._semantic = self._get_version_from_pkg_resources()
  File "/usr/local/lib/python2.7/dist-packages/pbr/version.py", line 448, in _get_version_from_pkg_resources
    result_string = packaging.get_version(self.package)
  File "/usr/local/lib/python2.7/dist-packages/pbr/packaging.py", line 755, in get_version
    name=package_name))
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name mock was given, but was not able to be found.

请帮助我。我在 python 2.7.2.

中使用 tensorflow 1.2.0

您的安装一定有问题。

请尝试以下命令:

pip install --upgrade mock pip install --upgrade distribute

如果它不起作用,您应该向我们提供有关如何安装 tensorflow 的更多详细信息(pip?conda?clone & setup.py?)并尝试从头开始重新安装。

希望对您有所帮助

我有同样的问题(但与 tensorflow 无关),在我的情况下,更新 setuptools 是解决方法。 我在这里找到了建议: https://github.com/testing-cabal/mock/issues/314

更新之前我有 setuptools 0.6c11,我已经更新到最新的 39.2.0。

pip install --upgrade setuptools

或者实际上在我的情况下,我不得不在本地下载和安装,因为生产服务器没有连接到互联网:

pip download setuptools

pip install setuptools-39.2.0-py2.py3-none-any.whl