Python BZ2 IOError: invalid data stream

匆匆过客 提交于 2019-12-23 19:07:46

问题


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)


回答1:


Could the issue be occuring because of the extra spacein 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()



回答2:


For me the issue was that the files were not in .bz2 format.



来源:https://stackoverflow.com/questions/30882145/python-bz2-ioerror-invalid-data-stream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!