Question: Entrez.esearch url bug
gravatar for jrj.healey
6 months ago by
United Kingdom
jrj.healey3.1k wrote:

Currently troubleshooting a Twitter bot that broke down, and it seems to be failing to retrieve from the Entrez API whereas it was working until about 2 weeks ago.

Has something changed in the Entrez API or is this a biopython issue?

It seems to come down to this, though there may be other issues we haven't gotten to yet.

>>> handle = Entrez.esearch(db="pubmed", term="Alikhan NF", field="author", retmode="xml", retmax=10)
>>> record =
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/Bio/Entrez/", line 376, in read
    record =
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/Bio/Entrez/", line 205, in read
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/Bio/Entrez/", line 513, in externalEntityRefHandler
UnboundLocalError: local variable 'url' referenced before assignment

So it's complaining about the url being missing, but:

>>> handle.url

Anyone know if something changed recently?

biopython • 354 views
ADD COMMENTlink modified 6 months ago by Istvan Albert ♦♦ 75k • written 6 months ago by jrj.healey3.1k
gravatar for Istvan Albert
6 months ago by
Istvan Albert ♦♦ 75k
University Park, USA
Istvan Albert ♦♦ 75k wrote:

Something is not right with your setup.

Your code works for me, and, in addition, it is quite unlikely that a variable would be missing inside BioPython. That's really what that says there - it is not an API problem, it is a coding problem that claims that a variable is not initialized at all.

Perhaps reinstall the package.

ADD COMMENTlink modified 6 months ago • written 6 months ago by Istvan Albert ♦♦ 75k

Right you are. Unbeknownst to me, the requirements.txt was using biopython 1.65. Moving to 1.70 seems to have fixed it.

ADD REPLYlink written 6 months ago by jrj.healey3.1k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 496 users visited in the last hour