Python 错误 : Unexpected end of data while reading a . tar 文件

标签 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

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

最佳答案

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

关于Python 错误 : Unexpected end of data while reading a . tar 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44368599/

相关文章:

python - 对角化+可训练的自定义 Tensorflow 层

python - python tarfile 中 tar --strip 的等效功能,用于随机命名的子文件夹

python - "Resource exhausted: OOM when allocating tensor"在重新训练 GPT 2 模型 : 期间

python - 在 Pandas pivot_table 中排序

python - 按 Multiindex 级别 2 上的位置对 pandas 数据帧进行切片

c++ - TF_NewTensor 分割错误 : Possible Bug?

javascript - 如何在Python中获取JavaScript内容

tensorflow - 为什么 Tensorflow 对象检测禁用 Faster R-CNN 的正则化

python - 如何在 Python 3.6 中的 tarfile 对象上使用 csv.DictReader?

python - 如何确定数据是否是没有文件的有效 tar 文件?