[Python] Can't get pybtex to parse BibTeX data

Discussão em 'Python' iniciado por Stack, Agosto 25, 2025.

  1. Stack

    Stack Membro Participativo

    I've tried feeding pybtex as bland a BibTeX spec as I could come up with. I've tried putting it into a file and using parse_file(). I can't get pybtex to succeed at parsing anything. Here's a minimum [not] working example (not working in python 3.12.3 on Ubuntu 24.04.2 LTSF):

    #!/usr/bin/python3

    import pybtex.database

    if __name__ == '__main__':
    bib_as_string = """
    \bib{Alpha}{article}{
    author = {Smith, Adam},
    title = {Wealth of Nations}
    }
    """

    bib_data = pybtex.database.parse_string(bib_as_string, 'bibtex')
    print(f'pybtex read in {len(bib_data.entries)} items.')
    print(f'\n{bib_data}')


    and the output it generates

    pybtex read in 0 items.

    BibliographyData(
    entries=OrderedCaseInsensitiveDict([]),

    preamble=[])


    What really obvious and simple thing am I missing?

    Continue reading...

Compartilhe esta Página