Drivebyluna
Drivebyluna

Reputation: 364

cannot import name 'etree' from 'lxml' in home brew installed package but fine in python shell

I'm trying to run ocrmypdf which was installed via homebrew but am having issues with my local version of lxml (version 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)

If I open up a python shell, I'm able to import just fine:

>>> from lxml import etree
>>> etree.__file__
'$HOME/anaconda3/lib/python3.7/site-packages/lxml/etree.cpython-37m-darwin.so'

My pythonpath:

$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

I'm not sure why the homebrewed package is not picking up the module file even though it says it's pointing to the same site-packages folder.

Upvotes: 0

Views: 478

Answers (0)

Related Questions