Imagemagick: Import Error: MagickWand shared library not found

Created on 22 Jan 2018  路  6Comments  路  Source: ImageMagick/ImageMagick

I am trying to use Wand but when I run my script I get this error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wand/api.py", line 180, in <module>
    libraries = load_library()`
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wand/api.py", line 135, in load_library
    raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
OSError: cannot find library; tried paths: ['/opt/local/lib/libMagickWand.dylib', '/opt/local/lib/libMagickWandHDRI.dylib', '/opt/local/lib/libMagickWandHDRI-2.dylib', '/opt/local/lib/libMagickWand-6.dylib', '/opt/local/lib/libMagickWand-6HDRI.dylib', '/opt/local/lib/libMagickWand-6HDRI-2.dylib', '/opt/local/lib/libMagickWand-Q16.dylib', '/opt/local/lib/libMagickWand-Q16HDRI.dylib', '/opt/local/lib/libMagickWand-Q16HDRI-2.dylib', '/opt/local/lib/libMagickWand-Q8.dylib', '/opt/local/lib/libMagickWand-Q8HDRI.dylib', '/opt/local/lib/libMagickWand-Q8HDRI-2.dylib', '/opt/local/lib/libMagickWand-6.Q16.dylib', '/opt/local/lib/libMagickWand-6.Q16HDRI.dylib', '/opt/local/lib/libMagickWand-6.Q16HDRI-2.dylib']

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "TestReadNameMethod.py", line 6, in <module>
    from wand.image import Image
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wand/image.py", line 20, in <module>
    from .api import MagickPixelPacket, libc, libmagick, library
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wand/api.py", line 206, in <module>
    'Try to install:\n  ' + msg)
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
  brew install freetype imagemagick

I am importing from wand.image import Image and have used pip install wand and have checked that I have the latest version 0.4. I have also installed the latest version of ImageMagick but a lot of the forums I've looked on with people having similar errors or this exact one explained that it might have to do with version 7 of ImageMagick and that I should uninstall and reinstall version 6. I've tried this but get the same error. When I ran brew search imagemagick in addition to imagemagick, imagemagick@6 showed up as a tap as well which I tried to avail. When I run brew install freetype it says that version 2.9 is already installed. I've asked brew doctor as well which gave this warning Warning: You have unlinked kegs in your Cellar Leaving kegs unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. Run `brew link` on these: python3 I ran brew link python3 and got this output:

Linking /usr/local/Cellar/python3/3.6.3... 
Error: Could not symlink bin/2to3-3.6
Target /usr/local/bin/2to3-3.6
already exists. You may want to remove it:
  rm '/usr/local/bin/2to3-3.6'

To force the link and overwrite all conflicting files:
  brew link --overwrite python3

To list all files that would be deleted:
  brew link --overwrite --dry-run python3

So I am hesitant to continue with that option because I'm not really sure what will happen and if I'll mess things up further.
I also tried export MAGICK_HOME=/opt/local as suggested by Wand if python was not installed using MacPorts, which mine wasn't.

System Configuration


I'm running Mac OS X 10.13.1
Using Python 3.6
If I'm missing anything or want anymore information let me know. I've been searching through all these forums trying as many solutions as possible and still nothing. Even reinstalled python.

question

Most helpful comment

@mnnit-geek had the same issue this worked for me. I'm using Mac OS X 10.10.5

For those on mac and using homebrew, it seems like Wand doesn't support imagemagick 7 yet as mentioned in other answers.
There's a new brew formula for Imagemagick 6 which can be used to install the older version in the meanwhile:
brew install imagemagick@6
Create a symlink to this newly installed dylib file as mentioned in other answer to get things working.
ln -s /usr/local/Cellar/imagemagick@6/<your specific 6 version>/lib/libMagickWand-6.Q16.dylib /usr/local/lib/libMagickWand.dylib

https://stackoverflow.com/a/41772062

All 6 comments

I'm facing exactly the same problem Mac OS X 10.13.2

@mnnit-geek had the same issue this worked for me. I'm using Mac OS X 10.10.5

For those on mac and using homebrew, it seems like Wand doesn't support imagemagick 7 yet as mentioned in other answers.
There's a new brew formula for Imagemagick 6 which can be used to install the older version in the meanwhile:
brew install imagemagick@6
Create a symlink to this newly installed dylib file as mentioned in other answer to get things working.
ln -s /usr/local/Cellar/imagemagick@6/<your specific 6 version>/lib/libMagickWand-6.Q16.dylib /usr/local/lib/libMagickWand.dylib

https://stackoverflow.com/a/41772062

The error message should be changed to note the required version of imagemagick. Are PRs welcome for that?

Traceback (most recent call last):
File "/home/sxs/anaconda3/lib/python3.6/site-packages/wand/api.py", line 184, in
libraries = load_library()
File "/home/sxs/anaconda3/lib/python3.6/site-packages/wand/api.py", line 139, in load_library
raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
OSError: cannot find library; tried paths: ['/ImageMagick-6.9.3/lib/libMagickWand.so', '/ImageMagick-6.9.3/lib/libMagickWandHDRI.so', '/ImageMagick-6.9.3/lib/libMagickWandHDRI-2.so', '/ImageMagick-6.9.3/lib/libMagickWand-6.so', '/ImageMagick-6.9.3/lib/libMagickWand-6HDRI.so', '/ImageMagick-6.9.3/lib/libMagickWand-6HDRI-2.so', '/ImageMagick-6.9.3/lib/libMagickWand-Q16.so', '/ImageMagick-6.9.3/lib/libMagickWand-Q16HDRI.so', '/ImageMagick-6.9.3/lib/libMagickWand-Q16HDRI-2.so', '/ImageMagick-6.9.3/lib/libMagickWand-Q8.so', '/ImageMagick-6.9.3/lib/libMagickWand-Q8HDRI.so', '/ImageMagick-6.9.3/lib/libMagickWand-Q8HDRI-2.so', '/ImageMagick-6.9.3/lib/libMagickWand-6.Q16.so', '/ImageMagick-6.9.3/lib/libMagickWand-6.Q16HDRI.so', '/ImageMagick-6.9.3/lib/libMagickWand-6.Q16HDRI-2.so']

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "pdf_anaylse.py", line 139, in
scale = get_img_scale(pdf_dir=pdf_dir, output_dir=img_out, resolution=None)
File "pdf_anaylse.py", line 36, in get_img_scale
im = page.to_image(resolution=resolution)
File "/home/sxs/yuhsuan/pdfplumber/pdfplumber/page.py", line 254, in to_image
from .display import PageImage, DEFAULT_RESOLUTION
File "/home/sxs/yuhsuan/pdfplumber/pdfplumber/display.py", line 3, in
import wand.image
File "/home/sxs/anaconda3/lib/python3.6/site-packages/wand/image.py", line 20, in
from .api import MagickPixelPacket, libc, libmagick, library
File "/home/sxs/anaconda3/lib/python3.6/site-packages/wand/api.py", line 210, in
'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

How to to solve this on linux?

To fellow random Googlers: if you're getting this only while deploying to uwsgi, remove limit-as from uwsgi configuration (more).

hey,magickwand shared library not found but i install magicwand and also give path to the variables

Was this page helpful?
0 / 5 - 0 ratings