6

Good morning,

After a lot of attemps running

from wand.image import Image

I get the following error:

    Traceback (most recent call last):
  File "C:\Users\XXXXX\PycharmProjects\PDF_convert\venv\lib\site-packages\wand\api.py", line 180, in <module>
    libraries = load_library()
  File "C:\Users\XXXXX\PycharmProjects\PDF_convert\venv\lib\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: ['C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWandHDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWandHDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-6.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-6.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-6HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-6HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-6HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-6HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-Q16.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-Q16.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-Q16HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-Q16HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-Q16HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-Q16HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-Q8.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-Q8.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-Q8HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-Q8HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-Q8HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-Q8HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-6.Q16.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-6.Q16.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-6.Q16HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-6.Q16HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-6.Q16HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-6.Q16HDRI-2.dll']
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 20, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\xxxxx\PycharmProjects\PDF_convert\venv\lib\site-packages\wand\image.py", line 20, in <module>
    from .api import MagickPixelPacket, libc, libmagick, library
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 20, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\XXXX\PycharmProjects\PDF_convert\venv\lib\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:
  http://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-windows

I have tried everything: 1. Install the most recent binaries ImageMagick-6.9.9-40-Q8-x64-dll (1).exe (checking the required options) 2. Define MAGICK_HOME path as: C:\Program Files\ImageMagick-6.9.9-Q8 3. Restart computer

and still giving me this error.

I'm using windows 10,

Can someone help me with this error? I really need to use this library for scanned ocr pdf.

Thanks in advance!win

jfqv
  • 83
  • 1
  • 2
  • 6
  • Possible duplicate of [Python doesn't find MagickWand Libraries (despite correct location?)](https://stackoverflow.com/questions/25003117/python-doesnt-find-magickwand-libraries-despite-correct-location) – emcconville Apr 25 '18 at 15:28

8 Answers8

5

Refer to this answer here. I had the same problem but I had a 32bit version of Python so I had to download the x86 version of ImageMagick.

byteme
  • 75
  • 5
3

For those who are in Linux

You also need to install magickwand from apt-get:

sudo apt-get install libmagickwand-dev
Anupam
  • 428
  • 7
  • 15
2

I faced the same issue on my Windows laptop to solve it I followed the following steps:

Run one of the following commands:

!conda install -c conda-forge/label/cf202003 imagemagick
!pip install install libmagickwand-dev
!pip install ImageMagick

After this implement the steps mentioned on the following link:

#Install ImageMagick on Windows by following this page: https://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-windows

I have downloaded and installed ImageMagick-7.1.0-2-Q16-HDRI-x64-dll.exe

Restarted the kernel of my jupyter notebook. It solved my issue.

Note:

I am keeping this answer on this post and I have removed a similar answer from the Error: MagickWand shared library not found. You probably had not installed ImageMagick library. (even though I have)

Yogesh Awdhut Gadade
  • 2,498
  • 24
  • 19
  • How do u run the above code to install libmagickwand-dev & ImageMagic? I tried on Anaconda Prompt and it doesn't work – Peter Aug 27 '21 at 06:17
  • Look at other post: https://stackoverflow.com/questions/68948617/how-to-install-libmagickwand-dev-for-magickwand – Peter Aug 27 '21 at 06:18
2

For those coming from Mac

After installing ImageMagick, MAGICK_HOME and PATH needs to be set

brew install freetype ImageMagick
export MAGICK_HOME=/opt/homebrew/opt/imagemagick
export PATH=$MAGICK_HOME/bin:$PATH

Now executing python from the same shell should pickup ImageMagick/MagickWand

Restart the shell if export statements are added to zshrc

TLJ
  • 4,525
  • 2
  • 31
  • 46
VanagaS
  • 3,130
  • 3
  • 27
  • 41
  • Running `python3 -c "import wand.version;print(wand.version.MAGICK_VERSION)"` to confirm successful installation. It should print something like `ImageMagick 7.1.0-52 Q16-HDRI aarch64 20549 https://imagemagick.org` – TLJ Nov 27 '22 at 17:16
  • I actually had to set `MAGICK_HOME` to this path (note `Cellar` instead of `bin`), unfortunately with a specific version number: `export MAGICK_HOME=/opt/homebrew/Cellar/imagemagick/7.1.0-53` – Martin Winter Dec 08 '22 at 14:08
1

Don't get confused check for correct Python Version:

It is not the Windows architecture 32/64bit that matters; what matters is which Python architecture is installed – 32 or 64bit.

To find out the Python version and architecture you have installed:
python -VV
>>> Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)]

Find the correct version x64 for 64bit x86 for 32bit Python:
https://imagemagick.org/download/binaries/

Get -dll.exe version...

Note that you have to check Install development headers and libraries for C and C++ to make Wand able to link to it.

Lastly you have to set MAGICK_HOME environment variable to the path of ImageMagick (e.g. C:\Program Files\ImageMagick-6.9.3-Q16). You can set it in Computer ‣ Properties ‣ Advanced system settings ‣ Advanced ‣ Environment Variables….

If you like to convert images like me you need to install Ghostscript in addition:
https://www.ghostscript.com/download/gsdnld.html

mhucka
  • 2,143
  • 26
  • 41
Fabian
  • 1,130
  • 9
  • 25
0

On windows, installing the 32bit version has worked for me, however, the link on wand's website is dead for some server reason. I have been able to make it work by installing from the binaries list.

http://www.imagemagick.org/download/binaries/ImageMagick-6.9.10-4-Q16-x86-dll.exe

will.mendil
  • 752
  • 2
  • 6
  • 21
0

Even installing the correct version (32-bit / 64-bit) of ImageMagick 7.X.X, I still got the ImportError: MagickWand shared library not found error. For my version of Wand==0.4.5, what helped for me was uninstalling ImageMagick, then installing a 6.9.X version. You may find the list of releases here.

user5305519
  • 3,008
  • 4
  • 26
  • 44
0

For Python v3 (64 bit),

try installing ImageMagick-6.9.10-2-Q16-x64-dll.exe from here then put installed directory file path in Path environment variable, ex - C:\Program Files\ImageMagick-6.9.10-Q16

then install wand pip install wand==0.4.4

this should fix the issue as there are compatibility issues with wand and ImageMagick

Mithilesh Tipkari
  • 697
  • 1
  • 10
  • 16