Python can't register CORE_RL_wand_.dll

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
roelandsch
Posts: 20
Joined: 2014-10-27T16:10:38-07:00
Authentication code: 6789

Python can't register CORE_RL_wand_.dll

Post by roelandsch »

I tried to use Wand via Python and it fails to load the module:

Code: Select all

Traceback (most recent call last):
  File "C:\Program Files\Python 3.5\lib\site-packages\wand\api.py", line 150, in <module>
    libraries = load_library()
  File "C:\Program Files\Python 3.5\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: ['C:\\Program Files\\ImageMagick-6.9.2-Q16-HDRI\\CORE_RL_wand_.dll', 'C:\\Program Files\\ImageMagick-6.9.2-Q16-HDRI\\CORE_RL_wand_HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.2-Q16-HDRI\\CORE_RL_wand_-6.dll', 'C:\\Program Files\\ImageMagick-6.9.2-Q16-HDRI\\CORE_RL_wand_-6HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.2-Q16-HDRI\\CORE_RL_wand_-Q16.dll', 'C:\\Program Files\\ImageMagick-6.9.2-Q16-HDRI\\CORE_RL_wand_-Q16HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.2-Q16-HDRI\\CORE_RL_wand_-Q8.dll', 'C:\\Program Files\\ImageMagick-6.9.2-Q16-HDRI\\CORE_RL_wand_-Q8HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.2-Q16-HDRI\\CORE_RL_wand_-6.Q16.dll', 'C:\\Program Files\\ImageMagick-6.9.2-Q16-HDRI\\CORE_RL_wand_-6.Q16HDRI.dll']
Both Python and ImageMagick are definitely 64-bit. And the DLL is found on the first location listed.

I did a quick test, and indeed simply trying to load that DLL fails:

Code: Select all

Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.cdll.CDLL(r"C:\Program Files\ImageMagick-6.9.2-Q16-HDRI\CORE_RL_magick_.dll")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python 3.5\lib\ctypes\__init__.py", line 417, in __getattr__
    dll = self._dlltype(name)
  File "C:\Program Files\Python 3.5\lib\ctypes\__init__.py", line 347, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
So I tried to install 32-bit Python and 32-bit ImageMagick. Same result, python can't load any of the DLLs.

What's going on here? Python is definitely loading other DLLs fine, is there something special to be done for the ImageMagick DLLs?

--
Roeland
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Python can't register CORE_RL_wand_.dll

Post by dlemstra »

Did you install the Visual C++ 2013 Redistributable Package (https://www.microsoft.com/en-us/downloa ... x?id=40784)?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
roelandsch
Posts: 20
Joined: 2014-10-27T16:10:38-07:00
Authentication code: 6789

Re: Python can't register CORE_RL_wand_.dll

Post by roelandsch »

No I didn't have the Visual C++ 2013 Redistributable installed, but installing it didn't make a difference.

Note that:
  • msvcp120.dll is included in the installation
  • ImageMagick itself (convert, etc) runs fine without having the Visual C++ 2013 Redistributable Package installed.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Python can't register CORE_RL_wand_.dll

Post by dlemstra »

Did you reboot after the installation? I have only seen 'The specified module could not be found' when the C++ redistributable was not installed.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
roelandsch
Posts: 20
Joined: 2014-10-27T16:10:38-07:00
Authentication code: 6789

Re: Python can't register CORE_RL_wand_.dll

Post by roelandsch »

I rebooted, but no change. Anyway thanks for taking the time to help me out.

Here are my current observations: Python version line:

Code: Select all

Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32
Output of ImageMagick -version:

Code: Select all

Version: ImageMagick 6.9.2-1 Q16 x64 2015-09-13 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180031101
Features: Cipher DPC HDRI Modules OpenMP
Delegates (built-in): bzlib cairo freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
roelandsch
Posts: 20
Joined: 2014-10-27T16:10:38-07:00
Authentication code: 6789

Re: Python can't register CORE_RL_wand_.dll

Post by roelandsch »

Well, I partially figured this out. You have to change the working directory to the ImageMagick installation directory. And more annoyingly, if your python script changes the working directory afterwards, then some images will fail to load because the coder DLL can't be loaded.

I verified MAGICK_HOME is set, and the registry contains a bunch of settings under HKEY_LOCAL_MACHINE\SOFTWARE\ImageMagick\6.9.2\Q:16 pointing to the right paths.

So I'm assuming the (python module) is responsible to properly set those load paths. Is reading those paths from the registry (or the environment variable) the supported way of figuring out where the DLL's are to be found?

There is also the issue of using those FILE* objects. Python and ImageMagick are compiled using different Visual C++ versions (resp. 2015 and 2013). So you'd not be able to pass a FILE* from Python to the ImageMagick DLL, right?

[edit: whining deleted]

regards,
Roeland
Post Reply