2

Update

Perhaps this is the cause?

>>> from ctypes import *
>>> cdll.LoadLibrary('libMagickWand-6.Q16.so.2')
...
OSError: /home/myuname/anaconda3/bin/../lib/libgomp.so.1: version `GOMP_4.0' not found (required by /usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16.so.2)

Unclear how to fix though.


Using the python wand package. Followed installation instructions by running:

sudo apt install libmagickwand-dev imagemagick
pip install wand

But I get the following error when trying to import Image:

>>> from wand.image import Image
...
    raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
OSError: cannot find library; tried paths: ['libMagickWand-6.Q16.so.2', 'libMagickWand-6.Q16.so.2']

During handling of the above exception, another exception occurred:
...
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
  apt-get install libmagickwand-dev

Not sure what's going on. Running ldconfig -p | grep -i wand gives me:

libMagickWand-6.Q16.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16.so.2
libMagickWand-6.Q16.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16.so

Also running ctypes shows the library:

>>> from ctypes.util import find_library
>>> find_library('MagickWand')
'libMagickWand-6.Q16.so.2'

Confirm that it's not v7:

$ convert -version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2017-05-26 http://www.imagemagick.org

1 Answers1

2

Install wand in Ubuntu 16.04 from the default Ubuntu repositories.

sudo apt install python-wand libmagickwand-dev 

Create an image called mona-lisa.png in your own home directory to use in the following example code from the wand documentation.

from wand.image import Image
from wand.display import display

with Image(filename='mona-lisa.png') as img:
    print(img.size)
    for r in 1, 2, 3:
        with img.clone() as i:
            i.resize(int(i.width * r * 0.25), int(i.height * r * 0.25))
            i.rotate(90 * r)
            i.save(filename='mona-lisa-{0}.png'.format(r))
            display(i)

If you are running this code from the terminal, press Enter twice after the end of the code to run the code. This code should run successfully and open the image in a separate window and show the console output. Close all the image windows that the Python code opened by clicking on the X before exiting from the Python interpreter.

I tried troubleshooting your output and got these results:

>>> from ctypes import *
>>> cdll.LoadLibrary('libMagickWand-6.Q16.so.2')
<CDLL 'libMagickWand-6.Q16.so.2', handle 266d6a0 at 7fb271c966d0>

There were no errors on my computer, however I discovered what caused this error on your computer:

OSError: /home/myuname/anaconda3/bin/../lib/libgomp.so.1: version `GOMP_4.0' not found (required by /usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16.so.2)

Clearly the error on your computer is caused by anaconda. Anaconda is known for making a big mess out of the default paths for many Python modules. To fix it you need to tell conda the paths to Python files that were installed by apt.

You can use symbolic links to tell conda the paths to Python files that were installed by apt. Put the symbolic links in conda's own lib/python/site-packages directory which for you would be something like: /home/ksindi/anaconda3/lib/python/site-packages if ksindi is your username.

No sir, I do not like anaconda for making me do all this extra work to make conda recognize the Python packages that I installed with apt.

karel
  • 122,292
  • 133
  • 301
  • 332