简体   繁体   中英

Python BZ2 IOError: invalid data stream

Traceback (most recent call last):
  File "TTRC_main.py", line 309, in <module>
    updater.start()
  File "TTRC_main.py", line 36, in start
    newFileData = bz2.BZ2File("C:/Program Files (x86)/Toontown Rewritten/temp/phase_7.mf.bz2"," rb").read()
IOError: invalid data stream

The code to retrieve file I'm getting that's giving me this error is:

newFileComp = urllib.URLopener()
newFileComp.retrieve("http://kcmo-1.download.toontownrewritten.com/content/phase_7.mf.bz2", "C:/Program Files (x86)/Toontown Rewritten/temp/phase_7.mf.bz2")

What do I do to fix this error? Its not really descriptive. (to me)

Could the issue be occuring because of the extra space in the file mode? -

newFileData = bz2.BZ2File("C:/Program Files (x86)/Toontown Rewritten/temp/phase_7.mf.bz2"," rb").read()

Try this -

newFileData = bz2.BZ2File("C:/Program Files (x86)/Toontown Rewritten/temp/phase_7.mf.bz2","rb").read()

对我来说,问题是文件不是 .bz2 格式。

  1. Make sure file is bz2 format.
  2. Make sure the read and write actions are the same "r","w" or "rb","wb"
  3. Like Anand said, no space in "rb".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM