OCRmyPDF icon indicating copy to clipboard operation
OCRmyPDF copied to clipboard

[Bug]: ocrmypdf v15.1.0+git8.2b0e1498 (snap): GPL Ghostscript 9.55.0: Can't find initialization file gs_init.ps. ghostscript.py:118

Open zWhdmB5T opened this issue 2 years ago • 16 comments

What were you trying to do?

System

  • OS: openSUSE Leap 15.5 x86_64
  • ocrmypdf v15.1.0+git8.2b0e1498 101 latest/stable shael7aerien - snapd 2.60.4 20290 latest/stable canonical✓ snapd

Bug

  • GPL Ghostscript 9.55.0: Can't find initialization file gs_init.ps. ghostscript.py:118

Where are you installing from?

Ubuntu snap

What operating system are you working on?

Linux

Relevant log output

Scanning contents     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 184/184 0:00:00
Start processing 4 pages concurrently                                                                                                                                            _sync.py:265
    1 GPL Ghostscript 9.55.0: Can't find initialization file gs_init.ps.                                                                                                   ghostscript.py:118
                                                                                                                                                                                             
OCR                   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0%   0/184 -:--:--
SubprocessOutputError: Ghostscript rasterizing failed                                                                                                                            _sync.py:450

zWhdmB5T avatar Oct 12 '23 23:10 zWhdmB5T

Command line?

jbarlow83 avatar Oct 13 '23 01:10 jbarlow83

Sorry… my regular command line /snap/bin/ocrmypdf --language deu+eng+grc+lat --output-type pdfa --rotate-pages --deskew --clean Test-PDF.pdf Test-PDF.pdf but also the same error for /snap/bin/ocrmypdf Test-PDF.pdf Test-PDF.pdf or /snap/bin/ocrmypdf Test-PDF.pdf Test-PDF-out.pdf

zWhdmB5T avatar Oct 13 '23 05:10 zWhdmB5T

addition: OCRmyPDF was working properly and find around one week ago, back then it was version 14.x.y by snap (can't remember specific version). It was recently updated automatically by snap to the version stated above and now throws the stated error. I haven't changed my system otherwise except for regular updates (but no installs or removes). I almost always use the command /snap/bin/ocrmypdf --language deu+eng+grc+lat --output-type pdfa --rotate-pages --deskew --clean Test-PDF.pdf Test-PDF.pdf I just shortened it for this case to /snap/bin/ocrmypdf Test-PDF.pdf Test-PDF-out.pdf

zWhdmB5T avatar Oct 13 '23 06:10 zWhdmB5T

Inside the snap the envvar GS_LIB is:

$ snap run --shell ocrmypdf
$ env
GS_LIB=$SNAP/usr/share/ghostscript/9.55/Resource/Init

whereas the actual installed location is $SNAP/usr/share/ghostscript/9.55.0/Resource/Init (note the .0)

This inconsistency seems like it has to do with Ubuntu's packaging of ghostscript.

The snap documentation is quite thin. Can't find any description of how to manage runtime environment variables and override this, or create a symlink within the image so that the two locations are equivalent. Can you offer any input?

jbarlow83 avatar Oct 13 '23 08:10 jbarlow83

just FYI: I did snap revert to ocrmypdf v14.2.1+git4.5a82ad63 75 latest/stable shael7aerien - Now, it works properly and fine again.

zWhdmB5T avatar Oct 13 '23 14:10 zWhdmB5T

Yes, the old image is based on Ubuntu 20.04 and new one is on 22.04. Ocrmypdf 15 doesn't support the 20.04 dependencies anymore, and the problem is something wrong with how Ghostscript is packaged in 22.04.

jbarlow83 avatar Oct 13 '23 19:10 jbarlow83

may you're running it on root try running it on user

Ccrlll avatar Oct 16 '23 08:10 Ccrlll

@brlin-tw Any chance you can help with this since you previously helped with the ocrmypdf snap?

jbarlow83 avatar Oct 17 '23 08:10 jbarlow83

Sure I'll check it out, no promises for any ETAs, though.

brlin-tw avatar Oct 17 '23 08:10 brlin-tw

I have this exact issue, tried the pip3 version, same issue.

loxK avatar Nov 02 '23 23:11 loxK

There are new Snap Edge releases at Install OCRmyPDF on Linux | Snap Store… Do they work? I am wondering a bit because @jbarlow83 hasn't said yet that the issue is resolved.

zWhdmB5T avatar Nov 10 '23 08:11 zWhdmB5T

The build script are configured to auto-release new versions of the main code, but I don't know much about snap or how to fix the snap-specific issues that are coming up. Snap is on the chopping block at this point - I tried to fix it, but I can't find answers to basic questions about how snap is supposed to work in its official documentation, so I'm hoping others with domain knowledge will be able to fix it.

jbarlow83 avatar Nov 10 '23 10:11 jbarlow83

OK, understood. Maybe, @brlin-tw can help as you asked him before. Or someone else having knowledge about Snap.

Hopefully, this issue can be resolved, so I can upgrade from v14 to v15 of OCRmyPDF Snap.

zWhdmB5T avatar Nov 10 '23 12:11 zWhdmB5T

OK, understood. Maybe, @brlin-tw can help as you asked him before. Or someone else having knowledge about Snap.

I plan to investigate this issue in the next few days, when there's any progress I'll make sure to let you know.

brlin-tw avatar Nov 10 '23 12:11 brlin-tw

@jbarlow83 @brlin-tw Sorry for this inquiry. Any news on this issue? Or is it unsolvable? (Would like to update my local snap after a while…)

zWhdmB5T avatar Feb 20 '24 10:02 zWhdmB5T

@jbarlow83 @brlin-tw Sorry for this inquiry. Any news on this issue?

Apologies for the ignorance, unfortunately I'm being out-of-capacity recently and got little time looking into it, I'll make sure to let you know if there's any progress(or, in a very unlikely event, not fixable).

brlin-tw avatar Apr 08 '24 10:04 brlin-tw

snap install ocrmypdf
 ocrmypdf --skip-text in.pdf  out.pdf

Scanning contents     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 91/91 0:00:00
Start processing 8 pages concurrently                                                                                              ocr.py:96
    1 Weight average image DPI is 321.7, max DPI is 600.0. The discrepancy may indicate a high detail region on this page,  _pipeline.py:477
but could also indicate a problem with the input PDF file. Page image will be rendered at 400.0 DPI.                                        
    2 GPL Ghostscript 9.55.0: Can't find initialization file gs_init.ps.                                                  ghostscript.py:139
                                                                                                                                            
   10 Weight average image DPI is 334.0, max DPI is 600.0. The discrepancy may indicate a high detail region on this page,  _pipeline.py:477
but could also indicate a problem with the input PDF file. Page image will be rendered at 400.0 DPI.                                        
OCR                   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0%  0/91 -:--:--
SubprocessOutputError: Ghostscript rasterizing failed  

omidraha avatar Jun 08 '24 03:06 omidraha

@omidraha the fix is only available in the channel latest/edge. See the dates and version (before updating) :

# snap info ocrmypdf
name:      ocrmypdf
summary:   OCRmyPDF adds a searchable text layer to scanned PDF files
publisher: James Barlow (shael7aerien)
store-url: https://snapcraft.io/ocrmypdf
license:   MPL-2.0
description: |
  OCRmyPDF packaged for snap
commands:
  - ocrmypdf
snap-id:      4gaxtpdrLWomuJZubaPeur6sfzfkG1Do
tracking:     latest/stable
refresh-date: Il y a 44 jours, à 15 h 51 HNR
channels:
  latest/stable:    v16.1.2+git14.0e013df1 2024-04-19 (149) 411MB -
  latest/candidate: ↑                                             
  latest/beta:      ↑                                             
  latest/edge:      v16.3.1+git18.964b30ca 2024-06-12 (159) 409MB -
installed:          v16.1.2+git14.0e013df1            (149) 411MB -

To install it you have to :

snap refresh ocrmypdf --channel latest/edge

loxK avatar Jun 13 '24 04:06 loxK

@jbarlow83 @loxK @omidraha FYI: latest latest/edge does work fine here. (I originally opened this ticket…)

zWhdmB5T avatar Jul 30 '24 07:07 zWhdmB5T