无法解析Python OCR库pypdfocr的依赖项

Ani*_*mik 6 python ocr python-3.x

我尝试使用以下命令安装pypdfocr:

pip install pypdfocr
pip install -i https://pypi.anaconda.org/pypi/simple pypdfocr
Run Code Online (Sandbox Code Playgroud)

但我不断收到错误消息:

File "C:\Users\888537\AppData\Local\Temp\pip-build-b4mwr93n\evernote\setup
.py", line 6
        exec x
             ^
    SyntaxError: Missing parentheses in call to 'exec'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\888537\A
ppData\Local\Temp\pip-build-b4mwr93n\evernote\
Run Code Online (Sandbox Code Playgroud)

以下是安装日志:

    [Anaconda3] C:\Users\888537>pip install -i https://pypi.anaconda.org/pypi/simple
 pypdfocr
Collecting pypdfocr
  Downloading https://pypi.anaconda.org/pypi/simple/pypdfocr/0.7.6/pypdfocr-0.7.
6.tar.gz
Requirement already satisfied (use --upgrade to upgrade): pillow>=2.2 in d:\anac
onda3\lib\site-packages (from pypdfocr)
Requirement already satisfied (use --upgrade to upgrade): reportlab>=2.7 in d:\a
naconda3\lib\site-packages (from pypdfocr)
Collecting watchdog>=0.6.0 (from pypdfocr)
  Downloading https://pypi.anaconda.org/pypi/simple/watchdog/0.8.1/watchdog-0.8.
1.tar.gz (154kB)
    100% |################################| 163kB 52kB/s
Requirement already satisfied (use --upgrade to upgrade): pypdf2>=1.23 in d:\ana
conda3\lib\site-packages (from pypdfocr)
Collecting evernote (from pypdfocr)
  Downloading https://pypi.anaconda.org/pypi/simple/evernote/1.25.0/evernote-1.2
5.0.tar.gz (140kB)
    100% |################################| 143kB 187kB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\888537\AppData\Local\Temp\pip-build-b4mwr93n\evernote\setup
.py", line 6
        exec x
             ^
    SyntaxError: Missing parentheses in call to 'exec'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\888537\A
ppData\Local\Temp\pip-build-b4mwr93n\evernote\
Run Code Online (Sandbox Code Playgroud)

如何使用pypdfocr库纠正此安装问题?

Dal*_*len 3

使用Python 2.x而不是3.x或找到出现语法错误的行并添加括号。

看,在 Python 3 中 exec 是一个函数,但在 Python 2 中 exec 是一个命令。

因此,在 Python 3 中,您必须将参数放入括号中才能正确调用 exec()。

因此,您尝试将适用于 Python 2 的包安装到 Python3。

至少安装脚本是。

好的,这就是我可以从错误日志中推断出的内容。我不熟悉 PyPDFOCR,尽管我怀疑它使用 tesseract 进行 OCRing,并且可能使用 PDFMiner 来访问 PDF 文档中的图像。

要继续使用 PIP,请首先下载而不是安装该软件包,然后更改 setup.py,然后执行 python setup.py install。

不过,如果脚本适用于 Python 2,则相关包可能仅适用于 Python 2。因为 pip 应该自动为已安装的 Python 选择正确的包版本。

所有的混乱可能都与 Anaconda 发行版有关。

祝你好运。