Getting MemoryError when opening large Zip file around 1.5GB in python 3.7.4


I am running the following code to caluclate CRC32 of ZIP file

buf = open("C:\\users\\Raj\\temp\\ZIPs\\XXX.ZIP",'rb').read()


If i restart the machines it works fine and after running this command for multiple times i am getting the same error

This is the code i am using for caluclating CRC of ZIP file more than a 1.5 GB

buf = open(zip_file,'rb').read()
buf = (binascii.crc32(buf) & 0xFFFFFFFF)
asked on Stack Overflow Oct 17, 2019 by Rajashekhara • edited Oct 17, 2019 by shaik moeed

1 Answer


You are not closing the opened zip file. Try this:

with open(zip_file,'rb') as handle:
    buf =
    buf = (binascii.crc32(buf) & 0xFFFFFFFF)
answered on Stack Overflow Oct 17, 2019 by gb_stackoverflow

User contributions licensed under CC BY-SA 3.0