I am trying to extract data from an LFW dataset using scikit-learn:
from sklearn.datasets import fetch_lfw_people
faces = fetch_lfw_people(min_faces_per_person=60)
In doing so, I get an import error message:
Python Image Library (PIL) is required to load data from jpeg files
The error message indicates that I need to install pillow . So I installed pillowJupyter from my laptop as follows:
!conda install
Now I can do it import PIL, but I still get the same error message when I try to retrieve data from the LFW dataset.
I am using Python 3.6. This is the full trace:
ImportError Traceback (most recent call last) ~\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\datasets\lfw.py in _load_imgs(file_paths, slice_, color, resize)
143 try:
145 except ImportError:
ImportError: cannot import name 'imread'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last) ~\AppData\Local\Continuum\anaconda3\lib\site-packages\scipy\misc\pilutil.py in <module>()
18 try:
20 except ImportError:
~\AppData\Local\Continuum\anaconda3\lib\site-packages\PIL\Image.py in <module>()
57
59 if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None):
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
ModuleNotFoundError Traceback (most recent call last) ~\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\datasets\lfw.py in _load_imgs(file_paths, slice_, color, resize)
145 except ImportError:
147 from scipy.misc import imresize
~\AppData\Local\Continuum\anaconda3\lib\site-packages\scipy\misc\pilutil.py in <module>()
20 except ImportError:
22 import ImageFilter
ModuleNotFoundError: No module named 'Image'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last) <ipython-input-236-6d1c601c92a3> in <module>()
~\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\datasets\lfw.py in fetch_lfw_people(data_home, funneled, resize, min_faces_per_person, color, slice_, download_if_missing)
333 faces, target, target_names = load_func(
334 data_folder_path, resize=resize,
336
337
~\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\externals\joblib\memory.py in __call__(self, *args, **kwargs)
560
561 def __call__(self, *args, **kwargs):
563
564 def __reduce__(self):
~\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\externals\joblib\memory.py in _cached_call(self, args, kwargs)
508 'directory %s'
509 % (name, argument_hash, output_dir))
511 if self.mmap_mode is not None:
512
~\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\externals\joblib\memory.py in call(self, *args, **kwargs)
742 if self._verbose > 0:
743 print(format_call(self.func, args, kwargs))
745 self._persist_output(output, output_dir)
746 duration = time.time() - start_time
~\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\datasets\lfw.py in _fetch_lfw_people(data_folder_path, slice_, color, resize, min_faces_per_person)
234 target = np.searchsorted(target_names, person_names)
235
237
238
~\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\datasets\lfw.py in _load_imgs(file_paths, slice_, color, resize)
147 from scipy.misc import imresize
148 except ImportError:
150 " is required to load data from jpeg files")
151
ImportError: The Python Imaging Library (PIL) is required to load data from jpeg files
Why am I getting this import error and how to fix it?