PHP can not load Imagick library - PHP Startup: Unable to load dynamic library

Vive picture Vive · Oct 30, 2018 · Viewed 14.8k times · Source

I have High Sierra OS - Version 10.13.6 PHP Version: PHP 7.1.9

when I try to do command php -v always appear error like this:

PHP Startup: Unable to load dynamic library '/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so' - dlopen(/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so, 9): Library not loaded: /usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.5.dylib
Referenced from: /usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so Reason: image not found in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so' - dlopen(/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so, 9): Library not loaded: /usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.5.dylib
Referenced from: /usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so Reason: image not found in Unknown on line 0 PHP 7.1.9 (cli) (built: Sep 14 2017 10:05:35) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.9, Copyright (c) 1999-2017, by Zend Technologies with Xdebug v2.5.3, Copyright (c) 2002-2017, by Derick Rethans

AFAIK, my php.ini failed to load imagick library. I already install Imagick with brew, there is a file imagick.so inside folder /usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/.

I already search many sources for this issue, I found many similar issues too in StackOverflow, it seems similar to mine but still not fixed my issue.

I can still run PHP script obviously, but cannot do some manipulation image with Imagick.

Answer

Ricardo Coelho picture Ricardo Coelho · Jul 17, 2020

Try:

sudo pecl uninstall imagick && sudo pecl install imagick