Search code examples
windowspython-2.7imagemagickwand

install wand on a windows machine


I tried to install wand 0.4.4 on a windows 7 (64 bit).

I installed imagemagick binary (ImageMagick-6.9.3-1-Q16-x64-dll.exe). Then set MAGICK_HOME environment variable to the path of ImageMagick. Finally, I installed wand through pip in Anaconda (python 2.7.13).

When I run 'from wand.image import Image' I get the following error:

    ----> 2 from wand.image import Image
  3 # from PIL import Image as PI
  D:\Anaconda2\lib\site-packages\wand\image.py in <module>()
 18 
 19 from . import compat
 ---> 20 from .api import MagickPixelPacket, libc, libmagick, library
 21 from .color import Color
 22 from .compat import (binary, binary_type, encode_filename, file_types,
D:\Anaconda2\lib\site-packages\wand\api.pyc in <module>()
178 
179 try:
--> 180     libraries = load_library()
181 except (OSError, IOError):
182     msg = 'http://docs.wand-py.org/en/latest/guide/install.html'
D:\Anaconda2\lib\site-packages\wand\api.pyc in load_library()
124         try:
125             tried_paths.append(libwand_path)
--> 126             libwand = ctypes.CDLL(libwand_path)
127             if libwand_path == libmagick_path:
128                 libmagick = libwand
D:\Anaconda2\lib\ctypes\__init__.pyc in __init__(self, name, mode, handle,      use_errno, use_last_error)
360 
361         if handle is None:
--> 362             self._handle = _dlopen(self._name, mode)
363         else:
364             self._handle = handle
TypeError: LoadLibrary() argument 1 must be string, not unicode

What's going wrong?


Solution

  • What's going wrong?

    This has been reported here. It'll most likely be fixed in the near-future.

    The fix is to update two lines in api.py.

    1. Locate file wand/api.py file.
    2. Search for methods ctypes.CDLL called under load_library function.
    3. Cast unicode variables to strings.
      1. Change ctypes.CDLL(libwand_path) to ctypes.CDLL(str(libwand_path))
      2. Change ctypes.CDLL(libmagick_path) to ctypes.CDLL(str(libmagick_path))