2016-06-14 86 views
3

我曾尝试使用命令安装pypdfocr:无法解析的Python的OCR库的依赖pypdfocr

pip install pypdfocr 
pip install -i https://pypi.anaconda.org/pypi/simple pypdfocr 

但我不断收到错误消息:

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\ 

以下是日志的安装:

[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\ 

我该如何纠正这个安装问题与pypdfocr图书馆?

回答

1

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

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

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

所以,你要安装的软件包Python3一个,就是为Python 2

至少安装脚本。好的,这就是我可以从错误日志中推断出来的东西。我对PyPDFOCR并不熟悉,但我怀疑它使用tesseract进行OCR,并且可能使用PDFMiner从PDF文档访问图像。

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

尽管如果一个脚本是针对Python 2的,那么可能是所涉及的软件包仅适用于Python 2.因为pip应该自动为已安装的Python选择正确的软件包版本。

所有的烂摊子都可能与Anaconda发行版有关。

祝你好运。

+0

非常感谢Dalen的帮助。 :)我能够通过在安装了Python 2.x的Anaconda中创建一个虚拟环境来解决问题。我在Python虚拟环境中成功安装了pypdfocr,因为安装的evernote依赖项在Python 2.x中没有任何错误。我之前使用的Python 3.4在安装依赖关系evernote时导致了问题。 –

+1

非常好!你走了更长的路,但如果你想继续使用蟒蛇,也许它是最好的。使用虚拟环境非常有创意。 +1。 – Dalen

+0

谢谢Dalen :) –

相关问题