GetRD / academic-file-converter

📚 Import Bibtex publications and Jupyter Notebook blog posts into your Markdown website or book. 将Bibtex转换为Markdown网站

Home Page:https://docs.hugoblox.com/reference/content-types/#automatically-import-publications-from-bibtex

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bibtexparser bug: 'str' object is not callable

aledeluca opened this issue · comments

I've had no luck with the publication import feature, so far. Running
academic import --bibtex file.bib
results in a
TypeError: 'str' object is not callable (with a long traceback), even when file.bib is as simple as the following:

@article{dummy,
	author = {T. Author},
	journal = {J. of Sci.},
	pages = {25--33},
	title = {Some short title},
	volume = {116},
	year = {2012}
}
commented

Please state your versions of Academic Admin and Python as well as providing the full traceback, which should locate the specific cause of the error.

OK, first of all: I tried on a different, Windows machine and everything worked. So, good news.

Right now I can't access the other machine (a Mac) where I had trouble, so I can't give you precise answers (but I will be able tomorrow). Anyway, when I opened this issue I had just installed Python3 from Homebrew, and Academic Admin from there using
pip3 install -U academic
so this might already be enough for you to understand the versions involved. I will write the full traceback (sorry for not including it earlier) tomorrow. Thank you very much for your help, and for developing Academic.

I had the same problem on my Mac OS X a few days ago after I installed python 3 with homebrew.

Then I installed miniconda3 (mini version of Anaconda Python 3) on Mac and installed academic admin tool (with pip install -U academic. I did not find pip3, but miniconda3 uses python3 by default. So pip should be equivalent to pip3. Make sure python and pip are from anaconda/miniconda3 before executing it). Then the error is gone and I was able to create a publication list.

You may want to try that, too. It is easy to install and use miniconda (or anaconda) python.

So the problem may be something to do with python 3 by homebrew.

Sorry for the delay.
Python v. 3.7.2 from Homebrew. Academic Admin v. 0.2.6.
Full traceback:

Traceback (most recent call last):
  File "/usr/local/bin/academic", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/academic/cli.py", line 77, in main
    import_bibtex(args.bibtex, pub_dir=args.publication_dir, featured=args.featured, overwrite=args.overwrite)
  File "/usr/local/lib/python3.7/site-packages/academic/cli.py", line 92, in import_bibtex
    bib_database = bibtexparser.load(bibtex_file, parser=parser)
  File "/usr/local/lib/python3.7/site-packages/bibtexparser/__init__.py", line 71, in load
    return parser.parse_file(bibtex_file)
  File "/usr/local/lib/python3.7/site-packages/bibtexparser/bparser.py", line 165, in parse_file
    return self.parse(file.read(), partial=partial)
  File "/usr/local/lib/python3.7/site-packages/bibtexparser/bparser.py", line 147, in parse
    self._expr.parseFile(bibtex_file_obj)
  File "/usr/local/lib/python3.7/site-packages/bibtexparser/bibtexexpression.py", line 263, in parseFile
    return self.main_expression.parseFile(file_obj, parseAll=True)
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 2362, in parseFile
    return self.parseString(file_contents, parseAll)
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 1804, in parseString
    loc, tokens = self._parse( instring, 0 )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 1548, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 4361, in parseImpl
    return super(ZeroOrMore, self).parseImpl(instring, loc, doActions)
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 4291, in parseImpl
    loc, tokens = self_expr_parse( instring, loc, doActions, callPreParse=False )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 1548, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 3871, in parseImpl
    ret = e._parse( instring, loc, doActions )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 1548, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 3722, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 1548, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 3871, in parseImpl
    ret = e._parse( instring, loc, doActions )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 1548, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 3722, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 1548, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 3705, in parseImpl
    loc, resultlist = self.exprs[0]._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 1581, in _parseNoCache
    tokens = fn( instring, tokensStart, retTokens )
  File "/usr/local/lib/python3.7/site-packages/pyparsing.py", line 1203, in wrapper
    ret = func(*args[limit[0]:])
  File "/usr/local/lib/python3.7/site-packages/bibtexparser/bibtexexpression.py", line 68, in field_to_pair
    strip_after_new_lines(f.get('Value')))
  File "/usr/local/lib/python3.7/site-packages/bibtexparser/bibtexexpression.py", line 25, in strip_after_new_lines
    return _strip_after_new_lines(s)
  File "/usr/local/lib/python3.7/site-packages/bibtexparser/bibtexexpression.py", line 10, in _strip_after_new_lines
    lines = s.splitlines()
TypeError: 'str' object is not callable
commented

Python 3.7 makes some major breaking changes to Python. Perhaps the dependency version of bibtexparser is incompatible with Python 3.7+...

commented

It was a bug upstream in Bibtexparser that has now been fixed: sciunto-org/python-bibtexparser#225 . Updating your Bibtexparser dependency or re-installing Academic Admin in a fresh environment should fix it.