当我打开终端并输入这些代码时,我已成功安装了pyPDF2 pyPdf-1.15
import os
from PyPDF2 import PdfFileReader
path = "F:/Download"
inputFileName = os.path.join(path, "RealPython.pdf")
inputFile = PdfFileReader(open(inputFileName, "rb"))
然后来了
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\PyPDF2\pdf.py", line 797, in __init__
self.read(stream)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\PyPDF2\pdf.py", line 1352, in read
xrefstream = readObject(stream, self)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\PyPDF2\generic.py", line 71, in readObject
return DictionaryObject.readFromStream(stream, pdf)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\PyPDF2\generic.py", line 587, in readFromStream
value = readObject(stream, pdf)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\PyPDF2\generic.py", line 62, in readObject
return ArrayObject.readFromStream(stream, pdf)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\PyPDF2\generic.py", line 158, in readFromStream
arr.append(readObject(stream, pdf))
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\PyPDF2\generic.py", line 73, in readObject
return readHexStringFromStream(stream)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\PyPDF2\generic.py", line 302, in readHexStringFromStream
txt += chr(int(x, base=16))
TypeError: int() got an unexpected keyword argument 'base'
我不知道我做错了什么,有什么帮助吗?
答案 0 :(得分:0)
错误:int() got an unexpected keyword argument 'base'
。这很可能与ironpython int函数实现有关。您可以尝试在PyPDF2包中编辑此文件:C:\Program Files (x86)\IronPython 2.7\lib\site-packages\PyPDF2\generic.py
(第302行,在readHexStringFromStream中)。将16
作为第二个位置参数传递给int:
#txt += chr(int(x, base=16))
txt += chr(int(x, 16))