ocrmypdf / OCRmyPDF

OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched
http://ocrmypdf.readthedocs.io/
Mozilla Public License 2.0
14.09k stars 1.02k forks source link

ocrmypdf does not run in Ubuntu 16.04 #387

Closed zenny closed 5 years ago

zenny commented 5 years ago

Hi,

The installation in Ubuntu 16.04 went well as described in https://ocrmypdf.readthedocs.io/en/latest/installation.html#ubuntu-16-04-lts

But when I try to 'ocrmypdf --help',

$  ocrmypdf --help
Traceback (most recent call last):
  File "/home/USER/.local/bin/ocrmypdf", line 6, in <module>
    from ocrmypdf.__main__ import run_pipeline
  File "/home/USER/.local/lib/python3.6/site-packages/ocrmypdf/__init__.py", line 46, in <module>
    from . import pdfinfo
  File "/home/USER/.local/lib/python3.6/site-packages/ocrmypdf/pdfinfo/__init__.py", line 32, in <module>
    from . import ghosttext
  File "/home/USER/.local/lib/python3.6/site-packages/ocrmypdf/pdfinfo/ghosttext.py", line 21, in <module>
    from ..exec import ghostscript
  File "/home/USER/.local/lib/python3.6/site-packages/ocrmypdf/exec/ghostscript.py", line 25, in <module>
    from PIL import Image
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 66, in <module>
    from PIL import _imaging as core
ImportError: cannot import name '_imaging'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "/home/USER/.local/bin/ocrmypdf", line 6, in <module>
    from ocrmypdf.__main__ import run_pipeline
  File "/home/USER/.local/lib/python3.6/site-packages/ocrmypdf/__init__.py", line 46, in <module>
    from . import pdfinfo
  File "/home/USER/.local/lib/python3.6/site-packages/ocrmypdf/pdfinfo/__init__.py", line 32, in <module>
    from . import ghosttext
  File "/home/USER/.local/lib/python3.6/site-packages/ocrmypdf/pdfinfo/ghosttext.py", line 21, in <module>
    from ..exec import ghostscript
  File "/home/USER/.local/lib/python3.6/site-packages/ocrmypdf/exec/ghostscript.py", line 25, in <module>
    from PIL import Image
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 66, in <module>
    from PIL import _imaging as core
ImportError: cannot import name '_imaging'

Tried without help:

$  pip3 install --user Pillow
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (3.1.2)

What libraries or packages are missing?

Thanks and cheers, /z

jbarlow83 commented 5 years ago

Ubuntu 16.04 seems to be refusing to allow you to install a more current version of Pillow than 3.1.2 because that is the system version. It also seems like this version of Pillow is broken because it's actually the C extension module of Pillow that is failing to load. Something seems unusual about this Ubuntu Python setup, that it is, I think it may be a non-standard or damaged configuration.

Perhaps try creating a virtual environment and install it there instead of installing with --user.