BadZipFile when Pillow is installed
Closed this issue · 1 comments
lfsando commented
When I use openpyxl to open a Workbook it throws BadZipFile: Bad CRC-32 for file 'xl/media/image2.jpg'
if Pillow is installed in the same environment. It works if I uninstall Pillow.
BadZipFile Traceback (most recent call last)
<ipython-input-2-f0a0b38a8395> in <module>
1 workbook_path = "scripts/Elaboração de Orçamento.xlsm"
----> 2 wb = openpyxl.load_workbook(workbook_path)
3 wb.guess_types = False
4
5 sheet = wb.get_sheet_by_name("Base Orçamentos")
~\.virtualenvs\project-nNknfD7x\lib\site-packages\openpyxl\reader\excel.py in load_workbook(filename, read_only, keep_vba, data_only, keep_links)
312 reader = ExcelReader(filename, read_only, keep_vba,
313 data_only, keep_links)
--> 314 reader.read()
315 return reader.wb
~\.virtualenvs\project-nNknfD7x\lib\site-packages\openpyxl\reader\excel.py in read(self)
277 self.read_theme()
278 apply_stylesheet(self.archive, self.wb)
--> 279 self.read_worksheets()
280 self.parser.assign_names()
281 if not self.read_only:
~\.virtualenvs\project-nNknfD7x\lib\site-packages\openpyxl\reader\excel.py in read_worksheets(self)
252 drawings = rels.find(SpreadsheetDrawing._rel_type)
253 for rel in drawings:
--> 254 charts, images = find_images(self.archive, rel.target)
255 for c in charts:
256 ws.add_chart(c, c.anchor)
~\.virtualenvs\project-nNknfD7x\lib\site-packages\openpyxl\reader\drawings.py in find_images(archive, path)
50 if dep.Type == IMAGE_NS:
51 try:
---> 52 image = Image(BytesIO(archive.read(dep.target)))
53 except OSError:
54 msg = "The image {0} will be removed because it cannot be read".format(dep.target)
C:\Python37\Lib\zipfile.py in read(self, name, pwd)
1427 """Return file bytes for name."""
1428 with self.open(name, "r", pwd) as fp:
-> 1429 return fp.read()
1430
1431 def open(self, name, mode="r", pwd=None, *, force_zip64=False):
C:\Python37\Lib\zipfile.py in read(self, n)
883 self._offset = 0
884 while not self._eof:
--> 885 buf += self._read1(self.MAX_N)
886 return buf
887
C:\Python37\Lib\zipfile.py in _read1(self, n)
987 if self._left <= 0:
988 self._eof = True
--> 989 self._update_crc(data)
990 return data
991
C:\Python37\Lib\zipfile.py in _update_crc(self, newdata)
915 # Check the CRC if we're at the end of the file
916 if self._eof and self._running_crc != self._expected_crc:
--> 917 raise BadZipFile("Bad CRC-32 for file %r" % self.name)
918
919 def read1(self, n):
BadZipFile: Bad CRC-32 for file 'xl/media/image2.jpg'
adamjsawicki commented