无法在Windows/Ubuntu上安装pdftotext

问题描述 投票:0回答:1

从几周以来,我一直在尝试安装

pdftotext
python
,但由于之前的poppler问题而面临挑战并失败。

最近我有:

  1. 升级
    Windows 10
    Windows 11
    以启用
    Sudo
    并使用
    apt
    命令
  2. 在 Windows 11 中为 apt- 命令安装了 WSL 和 Ubuntu 以及
  3. 运行以下命令:
sudo apt-get update
sudo apt install python3-pip
sudo apt-get install python-poppler
sudo apt install build-essential libpoppler-cpp-dev pkg-config python3-dev

一切都运行到这一点: enter image description here

问题: 现在,当我转到

cmd
并运行

pip install pdftotext

错误:

Collecting pdftotext
  Using cached pdftotext-2.2.2.tar.gz (113 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pdftotext
  Building wheel for pdftotext (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [11 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'pdftotext' extension
      creating build
      creating build\temp.win-amd64-cpython-39
      creating build\temp.win-amd64-cpython-39\Release
      "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.41.34120\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DPOPPLER_CPP_AT_LEAST_0_30_0=0 -DPOPPLER_CPP_AT_LEAST_0_58_0=0 -DPOPPLER_CPP_AT_LEAST_0_88_0=0 -IC:\Users\vinee\anaconda3\include -IC:\Users\vinee\anaconda3\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.41.34120\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" /EHsc /Tppdftotext.cpp /Fobuild\temp.win-amd64-cpython-39\Release\pdftotext.obj -Wall
      pdftotext.cpp
      C:\Users\vinee\anaconda3\include\pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pdftotext
  Running setup.py clean for pdftotext
Failed to build pdftotext
ERROR: Could not build wheels for pdftotext, which is required to install pyproject.toml-based projects

对于问题,我提到了这篇SO Post,它提到了关于安装

CMAKE
,我已经拥有并再次运行了

C:\Windows\System32>pip install Cmake
WARNING: Ignoring invalid distribution -cipy (c:\users\vinee\anaconda3\lib\site-packages)
Requirement already satisfied: Cmake in c:\users\vinee\anaconda3\lib\site-packages (3.30.4)
WARNING: Ignoring invalid distribution -cipy (c:\users\vinee\anaconda3\lib\site-packages)

但我仍然陷入构建轮错误。接下来我该怎么办。在这方面确实需要帮助。

python windows ubuntu pdftotext poppler
1个回答
0
投票

问题是您的 C++ 编译器找不到头文件。查看此问题,您需要确保已安装:Visual C++ Build Tools 核心功能、MSVC 工具集 C++、Visual C++ Redist 和 Windows 10(或在您的情况下为 Windows 11)SDK。我发现了另一个 response,其中 Windows SDK 解决了该问题。

另一个选项是使用

set INCLUDE
set LIB
命令告诉编译器头文件所在的位置。请记住,只有当您已将头文件安装在其他位置时,此选项才有效(有关更多信息,请参阅第一个链接)。

© www.soinside.com 2019 - 2024. All rights reserved.