How to properly import Wand to python?

13,912

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
Share:
13,912
dimensive
Author by

dimensive

Updated on July 06, 2022

Comments

  • dimensive
    dimensive almost 2 years

    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.

  • m2pathan
    m2pathan almost 7 years
    Hi, I am getting the error: TypeError: LoadLibrary() argument 1 must be string, not unicode
  • emcconville
    emcconville almost 7 years
    @m2pathan See this fix. Recent version of python/windows dropped auto-casting on ctypes, so you'll need to patch the api to enforce str(libmagick_path).