ImportError: MagickWand shared library not found - python

The below shows me trying to run my code with a response that the MagickWand shared library is not found and that imagemagick library is not installed. So I try to install, but it shows it's already installed? Any advice for next steps to trouble shoot?
python /Users/osx/Downloads/pdf_manage/main.py
Traceback (most recent call last):
File "/Users/osx/Downloads/pdf_manage/main.py", line 3, in <module>
from src.pdf_utils import PdfUtils
File "/Users/osx/Downloads/pdf_manage/src/pdf_utils.py", line 5, in <module>
from wand.image import Image as WandImage
File "/usr/local/lib/python2.7/site-packages/wand/image.py", line 20, in <module>
from .api import MagickPixelPacket, libc, libmagick, library
File "/usr/local/lib/python2.7/site-packages/wand/api.py", line 206, in <module>
'Try to install:\n ' + msg)
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
brew install freetype imagemagick
osx:~ osx$ brew install imageMagick
Warning: imagemagick 7.0.7-26 is already installed
osx:~ osx$ brew install freetype
Warning: freetype 2.9 is already installed
UPDATE- Running the below fixed my issue:
ln -s /usr/local/Cellar/imagemagick#6/6.9.9-38/lib/libMagickWand-6.Q16.dylib /usr/local/lib/libMagickWand.dylib

Related

Raspbian-Python3.9: ImportError: The _imagingft C module is not installed

I'm trying to run a simple code using PIL with custom fonts in Python3.9 in Raspbian, but i can't go past this error:
Traceback (most recent call last):
File "/home/pi/python/src/mintest.py", line 2, in <module>
font52 = ImageFont.truetype('fonts/Font.ttf', 52)
File "/home/pi/.local/lib/python3.9/site-packages/PIL/ImageFont.py", line 878, in truetype
return freetype(font)
File "/home/pi/.local/lib/python3.9/site-packages/PIL/ImageFont.py", line 875, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/home/pi/.local/lib/python3.9/site-packages/PIL/ImageFont.py", line 196, in __init__
if core.HAVE_RAQM:
File "/home/pi/.local/lib/python3.9/site-packages/PIL/ImageFont.py", line 70, in __getattr__
raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed
This is the minimum code needed to reproduce the error in Raspbian:
from PIL import ImageFont
font52 = ImageFont.truetype('fonts/Font.ttf', 52)
This is my system info
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.13 (stretch)
Release: 9.13
Codename: stretch
Python 3.9.6
Output of python3 -m PIL
I already tried all the answers i saw here.
Normally, I would have expected the solution to the issue:
The _imagingft C module is not installed
to be installing the Freetype library with:
sudo apt install libfreetype6-dev libfreetype6
However, it seems that the solution is:
sudo apt-get install libjpeg62-turbo-dev
pip3 install Pillow --no-binary :all:
I have no idea why - there is a discussion here.

macOS python3 with brew, error on import cv2

I installed python3 in my macOS through brew, I installed opencv and numpy, when I import cv2 and numpy I have this error
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
Traceback (most recent call last):
File "001.py", line 2, in <module>
import cv2
File "/usr/local/lib/python3.7/site-packages/cv2/__init__.py", line 89, in <module>
bootstrap()
File "/usr/local/lib/python3.7/site-packages/cv2/__init__.py", line 79, in bootstrap
import cv2
ImportError: numpy.core.multiarray failed to import
I fix the problem in this way:
I installed opencv using brew
brew install opencv
I installed opencv for python
pip install opencv-python
I removed (bad) numpy library
sudo rm -rf /usr/local/lib/python3.7/site-packages/numpy
I linked numpy library with working library
sudo ln -s /usr/local/Cellar/numpy/1.17.1/lib/python3.7/site-packages/numpy /usr/local/lib/python3.7/site-packages/numpy

Not able to execute from PIL import Image in anaconda python 3.6

I am unable to execute following
from PIL import Image
it returns me following:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "...\Anaconda3\lib\site-packages\PIL\Image.py", line 56, in <
module>
from . import _imaging as core
ImportError: DLL load failed: The specified module could not be found.
Currnetly using PIL version installed on anaconda 4.2.1. How to resolve this issue?
First, you can try:
conda update --all
If it doesn't help, this solution works for many people:
conda uninstall pillow
pip install pillow
Source: https://github.com/python-pillow/Pillow/issues/2945

pip installing eyeD3 module. Failed to find libmagic

Trying to install eyed3 but it's giving me this error:
>>> import eyed3
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
import eyed3
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\eyed3\__init__.py", line 35, in <module>
from .utils.log import log # noqa
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\eyed3\utils\__init__.py", line 27, in <module>
import magic
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\magic.py", line 176, in <module>
raise ImportError('failed to find libmagic. Check your installation')
ImportError: failed to find libmagic. Check your installation
Here's the pip install:
I tried to uninstall with pip and delete all the eyed3 files, then re-install and it still gave the same error. It also does the same thing with easy_install.
On Windows
You'll need DLLs for libmagic. #julian-r has uploaded a version of this project that includes binaries to pypi: https://pypi.python.org/pypi/python-magic-bin/0.4.14
pip install python-magic-bin==0.4.14
Works for me.
I fixed it by installing libmagic with this command
brew install libmagic
You need to install libmagic before you install eye3d.
Here is a link to the git.
https://github.com/ahupp/python-magic#dependencies
You can use this to install it:
pip install python-magic

Python 3.5 I can't install Pillow

I have installed Python 3.5.0rc3 amd64 and I need to install Pillow. So I downloaded it from http://www.lfd.uci.edu/~gohlke/pythonlibs/ Pillow‑2.9.0‑cp35‑none‑win_amd64.whl and I've also installed by pip successfully. But when I'm typing in interpreter from PIL import Image I got the following message:
File "C:\Program Files\Python 3.5\lib\site-packages\PIL\Image.py", line 63, in <module>
from PIL import _imaging as core
ImportError: DLL load failed: The specified module could not be found.
Moreover when I uninstalled this package and I was trying to install by easy_install I got another error:
Couldn't find a setup script in C:\Program Files\Python 3.5\Scripts\Pillow‑2.9.0‑cp35‑none‑win_amd64.whl.
What can I do?
Try this command on the command line:
python -m pip install pillow

Categories

Resources