ImageMagick Dependency and Colab Error
J22Melody opened this issue · comments
Hi here,
I got the same error as #7 when checking a Overleaf generated pdf file on macOS Monterey 12.2.1:
Traceback (most recent call last):
File "/Users/zifanjiang/opt/anaconda3/lib/python3.9/site-packages/wand/api.py", line 151, in <module>
libraries = load_library()
File "/Users/zifanjiang/opt/anaconda3/lib/python3.9/site-packages/wand/api.py", line 140, in load_library
raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
OSError: cannot find library; tried paths: []
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/zifanjiang/workspace/aclpubcheck/aclpubcheck/formatchecker.py", line 494, in <module>
main()
File "/Users/zifanjiang/workspace/aclpubcheck/aclpubcheck/formatchecker.py", line 491, in main
worker(submission, args.paper_type)
File "/Users/zifanjiang/workspace/aclpubcheck/aclpubcheck/formatchecker.py", line 454, in worker
return Formatter().format_check(submission=pdf_path, paper_type=paper_type)
File "/Users/zifanjiang/workspace/aclpubcheck/aclpubcheck/formatchecker.py", line 80, in format_check
self.check_page_margin(output_dir)
File "/Users/zifanjiang/workspace/aclpubcheck/aclpubcheck/formatchecker.py", line 284, in check_page_margin
im = self.pdf.pages[page].to_image(resolution=150)
File "/Users/zifanjiang/opt/anaconda3/lib/python3.9/site-packages/pdfplumber/page.py", line 356, in to_image
from .display import DEFAULT_RESOLUTION, PageImage
File "/Users/zifanjiang/opt/anaconda3/lib/python3.9/site-packages/pdfplumber/display.py", line 6, in <module>
from wand.image import Color as WandColor # type: ignore
File "/Users/zifanjiang/opt/anaconda3/lib/python3.9/site-packages/wand/image.py", line 18, in <module>
from . import assertions
File "/Users/zifanjiang/opt/anaconda3/lib/python3.9/site-packages/wand/assertions.py", line 155, in <module>
from .color import Color # noqa: E402
File "/Users/zifanjiang/opt/anaconda3/lib/python3.9/site-packages/wand/color.py", line 10, in <module>
from .api import library
File "/Users/zifanjiang/opt/anaconda3/lib/python3.9/site-packages/wand/api.py", line 175, in <module>
raise ImportError('MagickWand shared library not found.\n'
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
brew install freetype imagemagick
And still got the same error after either brew install freetype imagemagick
or brew install imagemagick@6
. So I assume this issue is not solved (for my environment).
Then I also tried to use Colab https://colab.research.google.com/drive/1Sq6ilmrFUQpUFMkV71U8-Wf0madW-Uer?usp=sharing.
I got another problem there: FileNotFoundError: [Errno 2] No such file or directory: '/etc/ImageMagick-6/policy.xml'
, which I can overcome by first mkdir /etc/ImageMagick-6/
and then running the code.
Then I got a similar error:
Checking paper.pdf
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/wand/api.py", line 151, in <module>
libraries = load_library()
File "/usr/local/lib/python3.7/dist-packages/wand/api.py", line 140, in load_library
raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
OSError: cannot find library; tried paths: []
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "aclpubcheck-main/aclpubcheck/formatchecker.py", line 494, in <module>
main()
File "aclpubcheck-main/aclpubcheck/formatchecker.py", line 491, in main
worker(submission, args.paper_type)
File "aclpubcheck-main/aclpubcheck/formatchecker.py", line 454, in worker
return Formatter().format_check(submission=pdf_path, paper_type=paper_type)
File "aclpubcheck-main/aclpubcheck/formatchecker.py", line 80, in format_check
self.check_page_margin(output_dir)
File "aclpubcheck-main/aclpubcheck/formatchecker.py", line 284, in check_page_margin
im = self.pdf.pages[page].to_image(resolution=150)
File "/usr/local/lib/python3.7/dist-packages/pdfplumber/page.py", line 356, in to_image
from .display import DEFAULT_RESOLUTION, PageImage
File "/usr/local/lib/python3.7/dist-packages/pdfplumber/display.py", line 6, in <module>
from wand.image import Color as WandColor # type: ignore
File "/usr/local/lib/python3.7/dist-packages/wand/image.py", line 18, in <module>
from . import assertions
File "/usr/local/lib/python3.7/dist-packages/wand/assertions.py", line 155, in <module>
from .color import Color # noqa: E402
File "/usr/local/lib/python3.7/dist-packages/wand/color.py", line 10, in <module>
from .api import library
File "/usr/local/lib/python3.7/dist-packages/wand/api.py", line 177, in <module>
'Try to install:\n ' + msg)
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
apt-get install libmagickwand-dev
I have attached a pdf file that got the error:
Unfortunately, this seems to be a problem at colab.
The Ubuntu they are using has a broken link to libmagickwand-dev
I had to change it to a manual install.
I really hope that they quickly solve it.
However, it should now work, at least in colab.
Can you confirm it?
Yes it works, thank you very much!