Python错误:读取.tar文件时意外的数据结束

时间:2017-06-05 12:07:31

标签: python tensorflow tarfile

我正在尝试运行TensorFlow的translate.py文件,但几秒钟后我就一直收到此错误:

tarfile.ReadError: unexpected end of data

我不知道为什么会发生这种情况,我尝试了几件事,包括自己下载所需的数据,并在代码中注释进行下载,但没有任何效果。

以下是我关注的网站: https://www.tensorflow.org/tutorials/seq2seq

如果您需要所有内容,以下是从命令到错误的行:

C:\Users\Mueller>python translate.py
Preparing WMT data in /tmp
Extracting tar file /tmp\training-giga-fren.tar
Traceback (most recent call last):
  File "translate.py", line 322, in <module>
    tf.app.run()
  File "C:\Users\Mueller\AppData\Local\Programs\Python\Python35\lib\site-package
s\tensorflow\python\platform\app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "translate.py", line 319, in main
    train()
  File "translate.py", line 173, in train
    FLAGS.data_dir, FLAGS.from_vocab_size, FLAGS.to_vocab_size)
  File "C:\Users\Mueller\data_utils.py", line 267, in prepare_wmt_data
    train_path = get_wmt_enfr_train_set(data_dir)
  File "C:\Users\Mueller\data_utils.py", line 83, in get_wmt_enfr_train_set
    corpus_tar.extractall(directory)
  File "C:\Users\Mueller\AppData\Local\Programs\Python\Python35\lib\tarfile.py",
 line 1996, in extractall
    numeric_owner=numeric_owner)
  File "C:\Users\Mueller\AppData\Local\Programs\Python\Python35\lib\tarfile.py",
 line 2038, in extract
    numeric_owner=numeric_owner)
  File "C:\Users\Mueller\AppData\Local\Programs\Python\Python35\lib\tarfile.py",
 line 2108, in _extract_member
    self.makefile(tarinfo, targetpath)
  File "C:\Users\Mueller\AppData\Local\Programs\Python\Python35\lib\tarfile.py",
 line 2156, in makefile
    copyfileobj(source, target, tarinfo.size, ReadError)
  File "C:\Users\Mueller\AppData\Local\Programs\Python\Python35\lib\tarfile.py",
 line 243, in copyfileobj
    raise exception("unexpected end of data")
tarfile.ReadError: unexpected end of data

有人知道这里发生了什么吗?

1 个答案:

答案 0 :(得分:4)

如果您的计算机在代理服务器后面运行,则下载的tar文件可能会被代理服务器剥离/阻止,从而导致下载的文件损坏。