You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux Mint 21.1安装PyPDF3失败,请求解决思路

解决Linux Mint 21.1上PyPDF3安装失败的问题

环境信息

kav@webdev:~$ cat /etc/issue
Linux Mint 21.1 Vera \n \l

kav@webdev:~$ python3 --version
Python 3.10.12
kav@webdev:~$
kav@webdev:~$ python3 -m pip --version
pip 25.1.1 from /home/kav/.local/lib/python3.10/site-packages/pip (python 3.10)
kav@webdev:~$ python3 -m pip install --upgrade pip setuptools wheel
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in ./.local/lib/python3.10/site-packages (25.1.1)
Requirement already satisfied: setuptools in ./.local/lib/python3.10/site-packages (80.9.0)
Requirement already satisfied: wheel in ./.local/lib/python3.10/site-packages (0.45.1)
kav@webdev:~$

安装报错信息

kav@webdev:~$ python3 -m pip install PyPDF3
Defaulting to user installation because normal site-packages is not writeable
Collecting PyPDF3
  Using cached PyPDF3-1.0.6.tar.gz (294 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  ¦ exit code: 1
  ?-> [43 lines of output]
      /home/kav/.local/lib/python3.10/site-packages/setuptools/dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated.
      !!

              ********************************************************************************
              Please consider removing the following classifiers in favor of a SPDX license expression:

              License :: OSI Approved :: BSD License

              See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
              ********************************************************************************

      !!
        self._finalize_license_expression()
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 35, in <module>
        File "/tmp/pip-install-bnuv6_o8/pypdf3_b5126c15a4cc4a86a69ed0c77f86a7f5/setup.py", line 32, in <module>
          setup(
        File "/home/kav/.local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 186, in setup
          return run_commands(dist)
        File "/home/kav/.local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 202, in run_commands
          dist.run_commands()
        File "/home/kav/.local/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1002, in run_commands
          self.run_command(cmd)
        File "/home/kav/.local/lib/python3.10/site-packages/setuptools/dist.py", line 1102, in run_command
          super().run_command(command)
        File "/home/kav/.local/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command
          cmd_obj.run()
        File "/home/kav/.local/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 312, in run
          self.find_sources()
        File "/home/kav/.local/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 320, in find_sources
          mm.run()
        File "/home/kav/.local/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 548, in run
          self.prune_file_list()
        File "/home/kav/.local/lib/python3.10/site-packages/setuptools/command/sdist.py", line 162, in prune_file_list
          super().prune_file_list()
        File "/home/kav/.local/lib/python3.10/site-packages/setuptools/_distutils/command/sdist.py", line 386, in prune_file_list
          base_dir = self.distribution.get_fullname()
        File "/home/kav/.local/lib/python3.10/site-packages/setuptools/_core_metadata.py", line 275, in get_fullname
          return _distribution_fullname(self.get_name(), self.get_version())
        File "/home/kav/.local/lib/python3.10/site-packages/setuptools/_core_metadata.py", line 293, in _distribution_fullname
          canonicalize_version(version, strip_trailing_zero=False),
      TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
?-> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
kav@webdev:~$

错误原因

PyPDF3是长期未维护的包(最后更新于2020年),其打包逻辑与最新版本的setuptools(80.9.0)不兼容,核心错误是canonicalize_version()函数参数不匹配。

解决方案

方案1:改用PyPDF2(推荐)

PyPDF2是PyPDF3的活跃分支,完全兼容原有功能且持续维护,直接执行安装命令:

python3 -m pip install PyPDF2 --user

方案2:降级setuptools后安装PyPDF3

如果必须使用PyPDF3,先降级setuptools到兼容版本再安装:

  1. 降级setuptools:
python3 -m pip install setuptools==65.5.0 --user
  1. 安装PyPDF3:
python3 -m pip install PyPDF3 --user
  1. (可选)安装完成后恢复setuptools到最新版本:
python3 -m pip install --upgrade setuptools --user

内容的提问来源于stack exchange,提问作者retired_developer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 22:24:55