question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When I try to run this snippet, I am getting an EOFError.

images = mnist.train_images()

# scipy.misc.toimage(scipy.misc.imresize(images[0,:,:] * -1 + 256, 10.))

Tracebacks are:

---------------------------------------------------------------------------
EOFError                                  Traceback (most recent call last)
<ipython-input-6-4d83ee5c3a9c> in <module>()
----> 1 images = mnist.train_images()
      2 
      3 # scipy.misc.toimage(scipy.misc.imresize(images[0,:,:] * -1 + 256, 10.))

~/Softwares/anaconda3/lib/python3.7/site-packages/mnist/__init__.py in train_images()
    159         columns of the image
    160     """
--> 161     return download_and_parse_mnist_file('train-images-idx3-ubyte.gz')
    162 
    163 

~/Softwares/anaconda3/lib/python3.7/site-packages/mnist/__init__.py in download_and_parse_mnist_file(fname, target_dir, force)
    144     fopen = gzip.open if os.path.splitext(fname)[1] == '.gz' else open
    145     with fopen(fname, 'rb') as fd:
--> 146         return parse_idx(fd)
    147 
    148 

~/Softwares/anaconda3/lib/python3.7/site-packages/mnist/__init__.py in parse_idx(fd)
    109                                     fd.read(4 * num_dimensions))
    110 
--> 111     data = array.array(data_type, fd.read())
    112     data.byteswap()  # looks like array.array reads data as little endian
    113 

~/Softwares/anaconda3/lib/python3.7/gzip.py in read(self, size)
    274             import errno
    275             raise OSError(errno.EBADF, "read() on write-only GzipFile object")
--> 276         return self._buffer.read(size)
    277 
    278     def read1(self, size=-1):

~/Softwares/anaconda3/lib/python3.7/gzip.py in read(self, size)
    480                 break
    481             if buf == b"":
--> 482                 raise EOFError("Compressed file ended before the "
    483                                "end-of-stream marker was reached")
    484 

EOFError: Compressed file ended before the end-of-stream marker was reached

​

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
datapythonistacommented, Oct 13, 2019

check what tempfile.gettempdir() returns, and that’s where the temporary files are. The names are train-images-idx3-ubyte.gz and similar, *-idx3-* should detect them.

2reactions
KasprzykMcommented, Oct 13, 2019

Oh god, thank you so much!

It is fixed. I found them in my C:\Users\User\AppData\Local\Temp folder and the zips there were incomplete/corrupted (?). Deleting them solved the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling EOFError Exception in Python - GeeksforGeeks
EOFError is raised when one of the built-in functions input() or raw_input() hits an end-of-file condition (EOF) without reading any data.
Read more >
Steps to Avoid EOFError in Python with Examples - eduCBA
2. EOFError is not an error technically, but it is an exception. When the in-built functions such as the input() function or read()...
Read more >
Python EOF error when reading input - Stack Overflow
EOF error is expected if no data is given when calling input or raw_input as explained in the documentation. Also, it's advisable to...
Read more >
EOFError: EOF when reading a line - DEV Community ‍ ‍
In Python, an EOFError is an exception that gets raised when functions such as input() or raw_input() in case of python2 return end-of-file...
Read more >
What an EOFError in Python is - Nailed it! - Maschituts
In Python, an EOFError is an exception that gets raised when functions such as input() and raw_input() return end-of-file (EOF) without ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found