PIL Module / Could not initialize images API - python

I'm running OSX and Python 2.7. The app I have requires the PIL module, which gives me this error when I try to install it.
I've tried several installations but nothing seems to do the trick. How do I get this to work?
WARNING 2012-04-18 18:15:54,222 dev_appserver.py:3394] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: dlopen(/Library/Python/2.7/site-packages/PIL/_imaging.so, 2): Symbol not found: _jpeg_resync_to_restart
Referenced from: /Library/Python/2.7/site-packages/PIL/_imaging.so
Expected in: flat namespace

The answer to this was uninstalling everything and then using pip install pil.

Related

Why am I getting " module 'cv2' has no attribute 'resize'"

I am using the following line in my program
img = cv2.resize(img, dsize=(299, 299), interpolation=cv2.INTER_LINEAR)
It is giving the following error
AttributeError: module 'cv2' has no attribute 'resize'
The type of image img is <class 'imageio.core.util.Array'>
I checked the official documentation of OpenCV and it contains the attribute resize.
Where am I going wrong?
The issue occurred due to the erroneous installation of OpenCV.
Although the system is behaving as OpenCV was properly installed. It wasn't installed properly.
Uninstalling and installing OpenCV again solved the issue.
pip uninstall opencv-python
and then
pip install opencv-python
Maybe your cv2 import is not correct. In a Python console, try
import cv2
help(cv2.resize)
In case it does not show the description of the resize method, the import does not work properly. Your could also check help(cv2)which gives a long list of all methods and attributes contained in the module.
Are you working within a virtual environment that needs activation first?

import error even after installing the utils in python3.6

I am trying to run an image recognition code. Even after installing 'utils' I am still getting error that module not found. What should I change?
Check if your python version is compatible. According to docs it's up to python 3.4 and you seem to be using 3.6. Source - https://pypi.org/project/python3-utils/#data

Importing numpy fails

I originally installed the anaconda distribution of python and have been coding primarily in Spyder. Recently I tried to install the Chaco visualization library and had a lot of trouble getting it to work using pip install - so instead I installed the Unthought Tool Suite which comes with Chaco. This means I now have two python distributions, but I'm not using virtualenv.
I get this error when running any code in Spyder using numpy:
ImportError:
dlopen(/Users/snoran/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-
packages/numpy/linalg/lapack_lite.so, 2): Library not loaded:
#rpath/lib/libmkl_intel_lp64.dylib Referenced from:
/Users/snoran/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-
packages/numpy/linalg/lapack_lite.so Reason: image not found
When importing bumpy throguh the IPython console, I get:
ImportError: cannot import name scimath
Does anyone have any suggestions on how to fix this?
I am using Mac OS X

Error importing mahotas in python (missing dll file)

I installed the mahotas library as the site says to but i keep getting the same error when i try to import the module:
Could not import submodules (exact error was: DLL load failed: The specified module could not be found.).
There are many reasons for this error the most common one is that you have
either not built the packages or have built (using `python setup.py build`) or
installed them (using `python setup.py install`) and then proceeded to test
mahotas **without changing the current directory**.
Try installing and then changing to another directory before importing mahotas.
Someone knows what i'm doing rong?
You seem to be on Windows.
For that platform, I recommend you try these compiled packages: http://www.lfd.uci.edu/~gohlke/pythonlibs/
(I'm the author of mahotas)

Is the Python Imaging Library not available on PyPI, or am I missing something?

easy_install pil results in an error:
Searching for pil
Reading http://pypi.python.org/simple/pil/
Reading http://www.pythonware.com/products/pil
Reading http://effbot.org/zone/pil-changes-115.htm
Reading http://effbot.org/downloads/#Imaging
No local packages or download links found for pil
error: Could not find suitable distribution for Requirement.parse(‘pil’)
Any ideas?
--
UPDATE:
Hm, asking it to find-links on the Python Ware site seems to be working:
easy_install -f http://www.pythonware.com/products/pil/ Imaging
Got a heap of warnings along the way though. I’ll see how it turns out.
--
UPDATE: I can import it in Python using import Image, but when I tell Django to syncdb I still get the following error:
Error: One or more models did not validate:
core.userprofile: “avatar”: To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .
I'm using an ImageField in one of my models.
Of course PIL is on PyPi! Specifically, it's right here.
easy_install is case-sensitive. The package is under PIL.
workaround is in easy_install PIL egg directory create link to this directory in name "PIL"
import Image
Django tries to import PIL directly:
from PIL import Image
You should check presence of PIL directory in your site-packages
from http://code.djangoproject.com/ticket/6054
It seems that there is something wrong with easy_install which installs PIL in the root namespace, installing from sources fixes this, strange.

Categories

Resources