}

Python3 and Pillow: ValueError: --enable-jpeg requested but jpeg not found, aborting.

Created:

The problem

When you install Pillow with python 3:

 File "/home/lcubo/.pyenv/versions/rest3/lib/python3.6/site-packages/setuptools/sandbox.py", line 278, in run               [46/412]
    return func()                                                                                                                    
  File "/home/lcubo/.pyenv/versions/rest3/lib/python3.6/site-packages/setuptools/sandbox.py", line 246, in runner                    
    _execfile(setup_script, ns)                                                                                                      
  File "/home/lcubo/.pyenv/versions/rest3/lib/python3.6/site-packages/setuptools/sandbox.py", line 47, in _execfile                  
    exec(code, globals, locals)                                                                                                      
  File "/tmp/easy_install-hzs4i7h2/Pillow-3.0.0/setup.py", line 767, in <module>                                                     
  File "/home/lcubo/.pyenv/versions/3.6.2/lib/python3.6/distutils/core.py", line 148, in setup                                       
    dist.run_commands()                                                                                                              
  File "/home/lcubo/.pyenv/versions/3.6.2/lib/python3.6/distutils/dist.py", line 955, in run_commands                                
    self.run_command(cmd)                                                                                                            
  File "/home/lcubo/.pyenv/versions/3.6.2/lib/python3.6/distutils/dist.py", line 974, in run_command                                 
    cmd_obj.run()                                                                                                                    
  File "/home/lcubo/.pyenv/versions/rest3/lib/python3.6/site-packages/setuptools/command/bdist_egg.py", line 161, in run             
    cmd = self.call_command('install_lib', warn_dir=0)                                                                               
  File "/home/lcubo/.pyenv/versions/rest3/lib/python3.6/site-packages/setuptools/command/bdist_egg.py", line 147, in call_command    
    self.run_command(cmdname)                                                                                                        
  File "/home/lcubo/.pyenv/versions/3.6.2/lib/python3.6/distutils/cmd.py", line 313, in run_command                                  
    self.distribution.run_command(command)                                                                                           
  File "/home/lcubo/.pyenv/versions/3.6.2/lib/python3.6/distutils/dist.py", line 974, in run_command                                 
    cmd_obj.run()                                                                                                                    
  File "/home/lcubo/.pyenv/versions/rest3/lib/python3.6/site-packages/setuptools/command/install_lib.py", line 11, in run            
    self.build()                                                                                                                     
  File "/home/lcubo/.pyenv/versions/3.6.2/lib/python3.6/distutils/command/install_lib.py", line 107, in build                        
    self.run_command('build_ext')                                                                                                    
  File "/home/lcubo/.pyenv/versions/3.6.2/lib/python3.6/distutils/cmd.py", line 313, in run_command                                  
    self.distribution.run_command(command)                                                                                           
  File "/home/lcubo/.pyenv/versions/3.6.2/lib/python3.6/distutils/dist.py", line 974, in run_command                                 
    cmd_obj.run()                                                                                                                    
  File "/home/lcubo/.pyenv/versions/3.6.2/lib/python3.6/distutils/command/build_ext.py", line 339, in run                            
    self.build_extensions()                                                                                                          
  File "/tmp/easy_install-hzs4i7h2/Pillow-3.0.0/setup.py", line 515, in build_extensions
ValueError: --enable-jpeg requested but jpeg not found, aborting.

Solution

Install libjpeg-dev:

sudo apt install libjpeg-dev

And recompile python 3, if you used pyenv:

pyenv uninstall 3.6.2
pyenv install 3.6.2