1
我一直試圖用bibtexparser模塊解析一些BibTeX記錄,即使使用bibtexparser documentation中找到的相同示例代碼,我也無法使它工作。通過PIP安裝bibtexparser導致不完整的模塊
的代碼是:
import bibtexparser
bibtex = """@ARTICLE{Cesar2013,
author = {Jean César},
title = {An amazing title},
year = {2013},
month = jan,
volume = {12},
pages = {12--23},
journal = {Nice Journal},
abstract = {This is an abstract. This line should be long enough to test
multilines...},
comments = {A comment},
keywords = {keyword1, keyword2}
}
"""
with open('bibtex.bib', 'w') as bibfile:
bibfile.write(bibtex)
with open('bibtex.bib') as bibtex_file:
bibtex_str = bibtex_file.read()
bib_database = bibtexparser.loads(bibtex_str)
print(bib_database.entries)
的錯誤是:
Traceback (most recent call last):
File "path-to-script...", line 12, in <module>
bib_database = bibtexparser.loads(bibtex_str)
AttributeError: 'module' object has no attribute 'loads'
Furthemore,當我嘗試列出bibtexparser, 「負荷」 的屬性和 「負荷」 是不是有:
dir(bibtexparser)
['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__version__', 'bparser', 'bwriter', 'customization', 'info', 'latexenc']
謝謝你的時間。
你從哪裏得到該模塊,因爲它看起來不完整。您可以從https://github.com/sciunto-org/python-bibtexparser獲取代碼。 – matsjoyce 2014-09-05 09:53:49
我從pip安裝它:pip安裝bibtexparser – alberto 2014-09-05 09:55:00
看起來像pip版本已損壞。從github鏈接下載zip(在右邊有一個標記爲「下載ZIP」的按鈕)。解壓zip,然後cd進入它並運行'python setup.py install'來重新安裝所有文件。如果你使用unix | linux,你可能需要'sudo python setup.py install' – matsjoyce 2014-09-05 10:00:54