Right you are. Unbeknownst to me, the requirements.txt was using biopython 1.65. Moving to 1.70 seems to have fixed it.
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 = Entrez.read(handle)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/Bio/Entrez/__init__.py", line 376, in read
record = handler.read(handle)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/Bio/Entrez/Parser.py", line 205, in read
self.parser.ParseFile(handle)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/Bio/Entrez/Parser.py", line 513, in externalEntityRefHandler
self.dtd_urls.append(url)
UnboundLocalError: local variable 'url' referenced before assignment
So it's complaining about the url being missing, but:
>>> handle.url
'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?term=Alikhan+NF&retmax=10&retmode=xml&tool=biopython&db=pubmed&field=author&email=gibsongroupbot%40gmail.com'
Anyone know if something changed recently?
1 answer
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.
Log in to answer this question.