Home>

I want to install libjpeg and fix the error

Error message
RuntimeError Traceback (most recent call last)
<ipython-input-20-cc23010c7de7>in<module>
      1 from sklearn.datasets import fetch_lfw_people
---->2 people = fetch_lfw_people (min_faces_per_person = 20, resize = 0.7)
      3 image_shape = people.images [0] .shape
      Four 
      5 fix, axes = plt.subplots (2, 5, figsize = (15, 8), subplot_kw = {"xticks": (), "yticks": ()})
~ \ 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, return_X_y)
    338 faces, target, target_names = load_func (
    339 data_folder_path, resize = resize,
->340 min_faces_per_person = min_faces_per_person, color = color, slice_ = slice_)
    341
    342 X = faces.reshape (len (faces), -1)
~ \ Anaconda3 \ lib \ site-packages \ joblib \ memory.py in __call __ (self, * args, ** kwargs)
    566
    567 def __call __ (self, * args, ** kwargs):
->568 return self._cached_call (args, kwargs) [0]
    569
    570 def __getstate __ (self):
~ \ Anaconda3 \ lib \ site-packages \ joblib \ memory.py in _cached_call (self, args, kwargs, shelving)
    532
    533 if must_call:
->534 out, metadata = self.call (* args, ** kwargs)
    535 if self.mmap_mode is not None:
    536 # Memmap the output at the first call to be consistent with
~ \ Anaconda3 \ lib \ site-packages \ joblib \ memory.py in call (self, * args, ** kwargs)
    732 if self._verbose>0:
    733 print (format_call (self.func, args, kwargs))
->734 output = self.func (* args, ** kwargs)
    735 self.store_backend.dump_item (
    736 [func_id, args_id], output, verbose = self._verbose)
~ \ Anaconda3 \ lib \ site-packages \ sklearn \ datasets \ lfw.py in _fetch_lfw_people (data_folder_path, slice_, color, resize, min_faces_per_person)
    227 target = np.searchsorted (target_names, person_names)
    228
->229 faces = _load_imgs (file_paths, slice_, color, resize)
    230
    231 # shuffle the faces with a deterministic RNG scheme to avoid having
~ \ Anaconda3 \ lib \ site-packages \ sklearn \ datasets \ lfw.py in _load_imgs (file_paths, slice_, color, resize)
    179 raise RuntimeError ("Failed to read the image file% s,"
    180 "Please make sure that libjpeg is installed"
->181% file_path)
    182
    183 face = np.asarray (img [slice_], dtype = np.float32)
RuntimeError: Failed to read the image file
C: \ Users \ scikit_learn_data \ lfw_home \ lfw_funneled \ Gerhard_Schroeder \ Gerhard_Schroeder_0030.jpg,
Please make sure that libjpeg is installed
Applicable source code
from sklearn.datasets import fetch_lfw_people
people = fetch_lfw_people (min_faces_per_person = 20, resize = 0.7)
image_shape = people.images [0] .shape
fix, axes = plt.subplots (2, 5, figsize = (15, 8), subplot_kw = {"xticks": (), "yticks": ()})
for target, image, ax in zip (people.target, people.images, axes.ravel ()):
    ax.imshow (image)
    ax.set_title (people.target_names [target])
  • Similar to other sites Ask https://www.lfd.uci.edu/~gohlke/pythonlibs .
  • Install according to the instructions on this site The error was not resolved.
Version

OS: windows10 version 1903 (build 18362.476)
Language: python 3.7.4
sklearn: 0.21.3

  • Answer # 1

    When I re-downloaded the image, it was found that the image of Gloria_Macapagal_Arroyo_0023.jpg was strange.

  • Answer # 2

    Is there a similar question with Stack Overflow?
    It seems that it is necessary to install DLL (will it be) if it is Windows instead of python module.

    I don't know how to install libjpeg in Python.

    It seems that it has finally been resolved, but since there is no specific solution, please try the trial and error with reference to the article. So if you get an error, why not ask additional questions?

  • Answer # 3

    As long as you see the error (displayed PATH), your Python environment looks like'anaconda3'.

    General package installation when using anaconda

    conda install (package name)


    Should be used andpipshould notinstall "Unofficial Window Package".(possibly destroying the original Anaconda environment)

    actually

    Unofficial Windows Binaries for Python Extension Packages

    Also on page
      

    The binaries are compatible with the most recent official CPython distributions on Windows>= 6.0. Chances are they do not work with custom Python distributions included with Blender, Maya, ArcGIS, OSGeo4W, ABAQUS, Cygwin, Pythonxy, Canopy, EPD, Anaconda, WinPython etc. Many binaries are not compatible with Windows XP or Wine.
      The binaries are compatible with the latest official CPython distribution, and may not work with Blender/(short)/Anaconda or any other custom distribution. (Pretty translation)

    There is a description of

    .

    In the first place Anaconda is in the initial state

    Numpy

    matplotlib

    Scikit-Learn

    Since everything in

    is already installed, it should work by default.