[Biopython] Bio.Entrez.epost error with Python 3.2

Nicolas Joannin nicolas.joannin at gmail.com
Sat Jan 26 12:42:19 UTC 2013


Hello everyone,

I am having trouble with using Bio.Entrez.epost: see details below.
I have tried converting the variables to bytes, but everything I've tried
gives the same error message.

I'm guessing that this might be a bug in biopython when used with Python 3.
If not, could you please tell me where I got this wrong, and how I can fix
it?

Best regards,
Nicolas


Here are the details:
I have tried the following:

   - post_h=Entrez.epost("nuccore",id="160418,160351")
   - post_h=Entrez.epost(b"nuccore",id=b"160418,160351")
   -
   post_h=Entrez.epost("nuccore".encode("utf-8"),id="160418,160351".encode("utf-8")


>>> post_h=Entrez.epost("nuccore",id="160418,160351")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/Bio/Entrez/__init__.py",
line 97, in epost
    return _open(cgi, variables, post=True)
  File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/Bio/Entrez/__init__.py",
line 436, in _open
    handle = urllib.request.urlopen(cgi, data=options)
  File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/urllib/request.py",
line 138, in urlopen
    return opener.open(url, data, timeout)
  File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/urllib/request.py",
line 367, in open
    req = meth(req)
  File
"/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/urllib/request.py",
line 1066, in do_request_
    raise TypeError("POST data should be bytes"
TypeError: POST data should be bytes or an iterable of bytes. It cannot be
str.


Nicolas Joannin, Ph.D.
Bioinformatics Center
Kyoto University, Uji campus, Japan



More information about the Biopython mailing list