8

I am running into some issues when I try to import Wand (an ImageMagick binding for Python).

Here's what's happening:

from wand.image import Image

getting the standard error message:

ImportError: No module named wand.image

Yes, Wand is installed, I used

pip install Wand

From what I understand, it depends on imagemagick so I also needed to do this:

brew install imagemagick

Still no luck. As far as I know, it should be able to import fine now, but it's not.

Other info: I am using homebrew on Mac and python 2.7 and I tried messing with virtual environments, but still couldn't get it to work. I have a hunch that I have something going wrong with my path, but I cannot figure out how to further troubleshoot this. I have uninstalled both imagemagick and wand and tried to reinstall them. I'm pretty inexperienced with python, any help is appreciated because I'm trying to learn! I read that I should check my sys.path, but when I print it I do not know what I'm checking for.

Thanks everyone.

dimensive
  • 175
  • 2
  • 2
  • 5

1 Answers1

3

Please use , and re-do a pip install of wand inside an activated sandbox.

# Install virtualenv system-wide
sudo pip install virtualenv

# Create a python sandbox
virtualenv my_sandbox

# Activate sandbox session
. ./my_sandbox/bin/activate

# Install wand into sandbox environment
pip install wand

# Test installation
python -mwand.version
#=> 0.4.2

How to properly import Wand to python?

You are correct in importing wand.image.Image with the following.

from wand.image import Image
# ...
with Image(filename='rose:') as img:
  pass
emcconville
  • 20,969
  • 4
  • 43
  • 60
  • Hi, I am getting the error: TypeError: LoadLibrary() argument 1 must be string, not unicode – m2pathan Apr 29 '17 at 13:28
  • 1
    @m2pathan See [this fix](https://github.com/dahlia/wand/issues/326). Recent version of python/windows dropped auto-casting on ctypes, so you'll need to patch the api to enforce `str(libmagick_path)`. – emcconville May 01 '17 at 13:44