4

Below error message:

device = XMLConverter(rsrcmgr, retstr, laparams=laparams, codec=codec)
TypeError: __init__() got an unexpected keyword argument 'codec'

Original Code:

rsrcmgr = PDFResourceManager()
retstr = BytesIO()
codec = 'utf-8'
laparams = LAParams()
device = XMLConverter(rsrcmgr, retstr, laparams=laparams, codec=codec)

This is surprisingly working fine in my project setup (python 3.5.3) but not in the new setup (python 3.7.4). Not sure if the this is anyways a problem or if a new version of XMLConverter is now available

Subash Nadar
  • 101
  • 2
  • 6
  • which module do you get XMLConverter from? and what version do you have installed in each env? – Chris Doyle Dec 24 '19 at 11:25
  • If this is from PDFMiner then indeed the XMLConverter class doesnt have a keyword `codec` in its method signature in the current version. `def __init__(self, rsrcmgr, outfp, pageno=1, laparams=None, imagewriter=None, stripcontrol=False):` – Chris Doyle Dec 24 '19 at 11:33
  • Yes Chris, you are right. The current version doesn't have codec keyword. Though 20181108 version does, and that is what is used in the other environment (stable app) – Subash Nadar Dec 27 '19 at 07:53

1 Answers1

5

As suspected by chris, this issue is due to version mismatch. 2019 version of pdfminer doesn't have keyword codec in the method. So I installed the older version of pdfminer 20181108 which is used in my project as well. Now the code runs without any error

Subash Nadar
  • 101
  • 2
  • 6