[Biopython] [Entrez] bytes objects has no attribute 'read'

Joshua Klein mobiusklein at gmail.com
Sat Dec 19 16:58:52 UTC 2015


It looks like what’s happening here is that calling ZipFile.read() returns
bytes instead of a file-like object. To work around this, create an
instance of BytesIO from the result of z.read(), and pass that object to
Entrez.parse. BytesIO converts an in-memory byte string into a file-like
object which supports the interface the parser expects.
​

On Sat, Dec 19, 2015 at 8:28 AM, <c.buhtz at posteo.jp> wrote:

> On 2015-12-19 13:55 <c.buhtz at posteo.jp> wrote:
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> >   File "/usr/local/lib/python3.4/dist-packages/Bio/Entrez/Parser.py",
> > line 243, in parse text = handle.read(BLOCK)
> > AttributeError: 'bytes' object has no attribute 'read'
>
> btw. When using zipfile.extractall() and then open these extracted
> files with mode 'rb' it workes.
> But I don't want to waste resource with storing unnecessary files to
> the filesystem.
> --
> GnuPGP-Key ID 0751A8EC
> _______________________________________________
> Biopython mailing list  -  Biopython at mailman.open-bio.org
> http://mailman.open-bio.org/mailman/listinfo/biopython
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython/attachments/20151219/5f936f71/attachment.html>


More information about the Biopython mailing list