2013-11-27 4 views
0

Biopython 패키지를 사용하고 있지만 그 기능 중 하나에 문제가 있습니다. 나는 편지에 패키지 (here)의 문서를 다음 있어요 것은 :Biopython Entrez.read() 작동하지 않습니다.

이 내가 시도 것입니다 :

from Bio import Entrez 
Entrez.email = "[email protected]" 
handle = Entrez.einfo(db = "pubmed") 
record = Entrez.read(handle) 

나는이 오류를

File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python2.7/dist-packages/Bio/Entrez/__init__.py", line 367, in read 
    record = handler.read(handle) 
    File "/usr/local/lib/python2.7/dist-packages/Bio/Entrez/Parser.py", line 184, in read 
    self.parser.ParseFile(handle) 
    File "/usr/local/lib/python2.7/dist-packages/Bio/Entrez/Parser.py", line 300, in startElementHandler 
    raise ValidationError(name) 
Bio.Entrez.Parser.ValidationError: Failed to find tag 'DbBuild' in the DTD. To skip all tags that are not represented in the DTD, please call Bio.Entrez.read or Bio.Entrez.parse with validate=False. 

을 얻을 그래서 내가 무슨 짓을했는지 통역사는 다음을 권장하고 수행했습니다 :

record = Entrez.read(handle, validate = False) 

및 t 그의 오류는 내가 가지고있는 오류입니다 :

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python2.7/dist-packages/Bio/Entrez/__init__.py", line 367, in read 
    record = handler.read(handle) 
    File "/usr/local/lib/python2.7/dist-packages/Bio/Entrez/Parser.py", line 194, in read 
    raise NotXMLError(e) 
Bio.Entrez.Parser.NotXMLError: Failed to parse the XML data (syntax error: line 1, column 0). Please make sure that the input data are in XML format. 

이것이 작동하지 않는 이유는 무엇입니까?

답변

2

방금이 문제를 해결했습니다. 기본적으로, 나는

from Bio import Entrez 
Entrez.email = "[email protected]" 
handle = Entrez.einfo(db = "pubmed") 
record = Entrez.read(handle) 

을하고 그것이 오류를 제공 한 후, 내가 직접은 "에러 상태"여전히 있기 때문에 작동하지 않을 것이다

record = Entrez.read(handle, validate = False) 

를 호출 그래서 대신 다시 처리 선언과 다음과 같이 작동해야합니다.

handle = Entrez.einfo(db = "pubmed") 
record = Entrez.read(handle, validate = False) 
관련 문제