Python doesn't find MagickWand Libraries (despite correct location?)

大憨熊 提交于 2019-12-19 05:49:36

问题


I wanted to install the Python ImageMagick API wand and followed this site:

http://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-windows

However, when running a very simple test:

from wand.image import Image

I get the following output:

Traceback (most recent call last):

File "F:\PATHTO\Python34\lib\site-packages\wand\api.py", line 137, in libraries = load_library()

File "F:\PATHTO\Python34\lib\site-packages\wand\api.py", line 107, in load_library raise IOError('cannot find library; tried paths: ' + repr(tried_paths))

OSError: cannot find library; tried paths: ['F:\PATHTO\ImageMagick-6.8.9-Q16\CORE_RL_wand_.dll', 'F:\PATHTO\ImageMagick-6.8.9-Q16\CORE_RL_wand_HDRI.dll', 'F:\PATHTO\ImageMagick-6.8.9-Q16\CORE_RL_wand_-Q16.dll', 'F:\PATHTO\ImageMagick-6.8.9-Q16\CORE_RL_wand_-Q16HDRI.dll', 'F:\PATHTO\ImageMagick-6.8.9-Q16\CORE_RL_wand_-Q8.dll', 'F:\PATHTO\ImageMagick-6.8.9-Q16\CORE_RL_wand_-Q8HDRI.dll', 'F:\PATHTO\ImageMagick-6.8.9-Q16\CORE_RL_wand_-6.Q16.dll', 'F:\PATHTO\ImageMagick-6.8.9-Q16\CORE_RL_wand_-6.Q16HDRI.dll']

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:\PATHTO\Python\test.py", line 1, in import wand.image

File "F:\PATHTO\Python34\lib\site-packages\wand\image.py", line 20, in from .api import MagickPixelPacket, libc, libmagick, library

File "F:\PATHTO\Python34\lib\site-packages\wand\api.py", line 161, in '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

The is though, that the files that were tried to be found (e.g. CORE_RL_wand_.dll) are in the very place that they were not found in. So it seems I set the MAGICK_HOME env. variable correctly.

However (what seems to be displayed incorrectly) the paths to the wand api and to my Python installation are displayed with a single backslash in my commandline, while the paths to the ImageMagick folder are displayed with two of them.

I don't understand why this is the case (the env. variable uses single backslashes as in the linked site) and I don't know whether this is the problem or even related to it.


回答1:


I solved my own problem after THINKING about it ;)

I had the 32bit version of Python and the 64bit version of ImageMagick... after uninstalling ImageMagick and installing the 32bit version everything is fine.

Maybe this helps someone who runs into the same problem and comes here via Google ^^




回答2:


Had a similar problem, checked that correct architecture was installed matching python 3.x and it still didnt work. I was able to get it to work by using a few steps and I thought I'd post it here consolidated in case anyone had similar problems.

A few sources said that Image Magick 7.x is not compatible with magick Wand so make sure you're using 6.x. Additionally, "static" suffix versions do not work. The one that finally worked for me was "ImageMagick-6.9.8-10-Q8-x64-dll.exe"




回答3:


Just a note, this works the other way as well (in my case),I got the same error with 64 bit python and 32 bit Imagemagick. The python architecture (32 or 64 bit) appears to have to match ImageMagick's. Note however that ghostscript can be 32 bit and still work.




回答4:


I faced the similar issue however installing ImageMagick-6.9.x-x-Q16-x64-dll.exe di the trick... so it is quite evident that ImageMagick-6.9.10-11-Q16-x64-static.exe does not seem to be wroking..... Architecture for Python & Installer was 64 bit only.....

Uninstall ImageMagick-6.9.10-11-Q16-x64-static.exe then install ImageMagick-6.9.x-x-Q16-x64-dll.exe




回答5:


What I do to work:

  • OS: Windows server 2012
  • python: 3.7 (32bit)
  • install imageMagick: ImageMagick-7.0.8-49-Q16-x86-dll (32bit)
  • install ghostscript: gs927w32 (32bit)

Add environment path:

  • C:\Program Files (x86)\gs\gs9.27\bin

References:

  • http://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-windows
  • Python: Extract a page from a pdf as a jpeg


来源:https://stackoverflow.com/questions/25003117/python-doesnt-find-magickwand-libraries-despite-correct-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!