我正在尝试运行通过自制软件安装的 ocrmypdf,但我的本地版本的 lxml(版本 4.2.4)存在问题:
Traceback (most recent call last):
File "/usr/local/bin/ocrmypdf", line 5, in <module>
from ocrmypdf.__main__ import run
File "/usr/local/Cellar/ocrmypdf/9.8.2/libexec/lib/python3.8/site-packages/ocrmypdf/__init__.py", line 18, in <module>
from . import helpers, hocrtransform, leptonica, pdfa, pdfinfo
File "/usr/local/Cellar/ocrmypdf/9.8.2/libexec/lib/python3.8/site-packages/ocrmypdf/pdfa.py", line 38, in <module>
import pikepdf
File "/usr/local/Cellar/ocrmypdf/9.8.2/libexec/lib/python3.8/site-packages/pikepdf/__init__.py", line 54, in <module>
from .models import (
File "/usr/local/Cellar/ocrmypdf/9.8.2/libexec/lib/python3.8/site-packages/pikepdf/models/__init__.py", line 13, in <module>
from .metadata import PdfMetadata
File "/usr/local/Cellar/ocrmypdf/9.8.2/libexec/lib/python3.8/site-packages/pikepdf/models/metadata.py", line 17, in <module>
from lxml import etree
ImportError: cannot import name 'etree' from 'lxml' ($HOME/anaconda3/lib/python3.7/site-packages/lxml/__init__.py)
如果我打开一个 python shell,我可以很好地导入:
>>> from lxml import etree
>>> etree.__file__
'$HOME/anaconda3/lib/python3.7/site-packages/lxml/etree.cpython-37m-darwin.so'
我的蟒蛇路径:
$HOME/anaconda3/lib/python3.7/site-packages:$HOME/Code_Repos/invoice2data//src:$HOME/Code_Repos/invoice2data//src/invoice2data:$HOME/anaconda3/lib/python3.7/site-packages:$HOME/Code_Repos/invoice2data
我不确定为什么自制软件包没有拾取模块文件,即使它说它指向同一个站点包文件夹。