【问题标题】:Camelot: DeprecationError: PdfFileReader is deprecatedCamelot:弃用错误:PdfFileReader 已弃用
【发布时间】:2023-02-16 22:28:03
【问题描述】:

我一直在为您的项目使用 camelot,但自 2 天以来我收到以下错误消息。当尝试运行以下代码 sn-p 时:

import camelot
tables = camelot.read_pdf('C:\\Users\\user\\Downloads\\foo.pdf', pages='1')

我收到此错误:

DeprecationError: PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead.

我检查了这个文件,它确实使用了 pdfFileReader: c:\ProgramData\Anaconda3\lib\site-packages\camelot\handlers.py

我以为我可以指定 PyPDF2 的版本,但它会在我安装 camelot 时自动安装(因为该库被 camelot 使用)。你认为有什么解决方案可以手动指定 PyPDF2 的版本吗?

【问题讨论】:

  • 在camelot的需求中指定需要PyPDF2>=1.26.0。因此,只要您安装满足该要求的版本,一切都应该没问题。关于这个问题的 issue 已经存在于他们的 GitHub 上。
  • 你可以尝试手动安装包:pip install pypdf<3.0.0

标签: python pypdf python-camelot


【解决方案1】:

这是issues #339。

虽然希望很快会有一个包含修复的版本,但您仍然可以这样做:

pip install 'PyPDF2<3.0'

安装 camelot 之后。

有关详细信息和屏幕截图,请参阅https://github.com/camelot-dev/camelot/issues/339#issuecomment-1367331630。

【讨论】:

  • 我在 Colab 中尝试了 pip install PyPDF2&lt;3.0 但仍然收到错误 DeprecationError: PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead
  • 你还有PyPDF2&gt;=3.0。这个错误信息在 3.0 之前是不存在的。
  • @ChristineTan 我有同样的问题。仔细检查您的 PyPDF2 版本(pip3 显示 PyPDF2),如果低于 3.0,请重新启动您的内核/venv 并重新运行您的代码。
猜你喜欢
  • 1970-01-01
  • 2012-07-03
  • 2023-04-05
  • 1970-01-01
  • 1970-01-01
  • 2014-02-12
  • 1970-01-01
  • 2023-01-23
  • 1970-01-01
相关资源
最近更新 更多