The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.
Description:
During the installation of matplotlib package for python library using pip utility. I get a dependency error due to pillow package during compilation. It seems that there are some jpeg libraries missing for pillow package.
Linux distribution:
[root@localhost oracle]# uname -a
Linux localhost 5.4.17-2136.311.6.1.el8uek.x86_64 #2 SMP Thu Sep 22 19:29:28 PDT 2022 x86_64 x86_64 x86_64 GNU/Linux
PIP version:
[root@localhost oracle]# pip3 --version
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)
Error message:
[root@localhost oracle]# pip3 install matplotlib
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting matplotlib
Using cached https://files.pythonhosted.org/packages/09/03/b7b30fa81cb687d1178e085d0f01111ceaea3bf81f9330c937fb6f6c8ca0/matplotlib-3.3.4-cp36-cp36m-manylinux1_x86_64.whl
Requirement already satisfied: numpy>=1.15 in /usr/local/lib64/python3.6/site-packages (from matplotlib)
Collecting pillow>=6.2.0 (from matplotlib)
Using cached https://files.pythonhosted.org/packages/7d/2a/2fc11b54e2742db06297f7fa7f420a0e3069fdcf0e4b57dfec33f0b08622/Pillow-8.4.0.tar.gz
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib64/python3.6/site-packages (from matplotlib)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /usr/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: six>=1.5 in /usr/lib/python3.6/site-packages (from python-dateutil>=2.1->matplotlib)
Installing collected packages: pillow, matplotlib
Running setup.py install for pillow ... error
...............
----------------------------------------
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-asr9d8dj/pillow/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-ncoxtssa-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-asr9d8dj/pillow/
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-asr9d8dj/pillow/setup.py", line 1037, in <module>
raise RequiredDependencyException(msg)
__main__.RequiredDependencyException:
The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
Steps Tried:
As per pillow documentation ” https://pillow.readthedocs.io/en/latest/installation.html “, i tried to install the base libraries required for pillow package, but they do not exist.
[root@localhost oracle]# sudo dnf install libtiff-devel libjpeg-devel openjpeg2-devel zlib-devel \
> freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel \
> harfbuzz-devel fribidi-devel libraqm-devel libimagequant-devel libxcb-devel
Last metadata expiration check: 1:54:35 ago on Thu 13 Oct 2022 03:38:18 PM IST.
No match for argument: openjpeg2-devel
Package zlib-devel-1.2.11-18.el8_5.x86_64 is already installed.
No match for argument: lcms2-devel
No match for argument: libraqm-devel
No match for argument: libimagequant-devel
Error: Unable to find a match: openjpeg2-devel lcms2-devel libraqm-devel libimagequant-devel
[root@hydrupgrd oracle]# /usr/bin/pip-3.6 install matplotlib
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip-3.6 install --user` instead.
Collecting matplotlib
Using cached https://files.pythonhosted.org/packages/09/03/b7b30fa81cb687d1178e085d0f01111ceaea3bf81f9330c937fb6f6c8ca0/matplotlib-3.3.4-cp36-cp36m-manylinux1_x86_64.whl
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib64/python3.6/site-packages (from matplotlib)
Requirement already satisfied: numpy>=1.15 in /usr/local/lib64/python3.6/site-packages (from matplotlib)
Collecting pillow>=6.2.0 (from matplotlib)
Using cached https://files.pythonhosted.org/packages/7d/2a/2fc11b54e2742db06297f7fa7f420a0e3069fdcf0e4b57dfec33f0b08622/Pillow-8.4.0.tar.gz
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /usr/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: six>=1.5 in /usr/lib/python3.6/site-packages (from python-dateutil>=2.1->matplotlib)
Installing collected packages: pillow, matplotlib
Running setup.py install for pillow ... error
......................................
The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
Traceback (most recent call last):
File "/tmp/pip-build-329pzc2x/pillow/setup.py", line 1024, in <module>
zip_safe=not (debug_build() or PLATFORM_MINGW),
File "/usr/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib64/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/usr/lib64/python3.6/distutils/command/install.py", line 556, in run
self.run_command('build')
File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib64/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 78, in run
_build_ext.run(self)
File "/usr/lib64/python3.6/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/tmp/pip-build-329pzc2x/pillow/setup.py", line 790, in build_extensions
raise RequiredDependencyException(f)
__main__.RequiredDependencyException: jpeg
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-329pzc2x/pillow/setup.py", line 1037, in <module>
raise RequiredDependencyException(msg)
__main__.RequiredDependencyException:
The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
----------------------------------------
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-329pzc2x/pillow/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-9etlruis-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-329pzc2x/pillow/
Solution:
Upgrade pip to higher version.
[root@hydrupgrd oracle]# python3 -m pip install --upgrade pip
WARNING: Running pip install with root privileges is generally not a good idea. Try `__main__.py install --user` instead.
Collecting pip
Downloading https://files.pythonhosted.org/packages/a4/6d/6463d49a933f547439d6b5b98b46af8742cc03ae83543e4d7688c2420f8b/pip-21.3.1-py3-none-any.whl (1.7MB)
100% |████████████████████████████████| 1.7MB 1.1MB/s
Installing collected packages: pip
Successfully installed pip-21.3.1
You are using pip version 21.3.1, however version 22.2.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@hydrupgrd oracle]# pip install --upgrade pip
Requirement already satisfied: pip in /usr/local/lib/python3.6/site-packages (21.3.1)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
[root@hydrupgrd oracle]# pip3 install seaborn
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Collecting seaborn
Using cached seaborn-0.11.2-py3-none-any.whl (292 kB)
Requirement already satisfied: numpy>=1.15 in /usr/local/lib64/python3.6/site-packages (from seaborn) (1.19.5)
Requirement already satisfied: scipy>=1.0 in /usr/local/lib64/python3.6/site-packages (from seaborn) (1.5.4)
Requirement already satisfied: pandas>=0.23 in /usr/local/lib64/python3.6/site-packages (from seaborn) (1.1.5)
Collecting matplotlib>=2.2
Using cached matplotlib-3.3.4-cp36-cp36m-manylinux1_x86_64.whl (11.5 MB)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/site-packages (from matplotlib>=2.2->seaborn) (0.11.0)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/site-packages (from matplotlib>=2.2->seaborn) (2.8.2)
Collecting pillow>=6.2.0
Downloading Pillow-8.4.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB)
|████████████████████████████████| 3.1 MB 4.4 MB/s
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib64/python3.6/site-packages (from matplotlib>=2.2->seaborn) (1.3.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /usr/lib/python3.6/site-packages (from matplotlib>=2.2->seaborn) (2.1.10)
Requirement already satisfied: pytz>=2017.2 in /usr/lib/python3.6/site-packages (from pandas>=0.23->seaborn) (2017.2)
Requirement already satisfied: six>=1.5 in /usr/lib/python3.6/site-packages (from python-dateutil>=2.1->matplotlib>=2.2->seaborn) (1.11.0)
Installing collected packages: pillow, matplotlib, seaborn
Successfully installed matplotlib-3.3.4 pillow-8.4.0 seaborn-0.11.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
[root@hydrupgrd oracle]# pip3 install matplotlib
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Requirement already satisfied: matplotlib in /usr/local/lib64/python3.6/site-packages (3.3.4)
Requirement already satisfied: pillow>=6.2.0 in /usr/local/lib64/python3.6/site-packages (from matplotlib) (8.4.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /usr/lib/python3.6/site-packages (from matplotlib) (2.1.10)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib64/python3.6/site-packages (from matplotlib) (1.3.1)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/site-packages (from matplotlib) (2.8.2)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/site-packages (from matplotlib) (0.11.0)
Requirement already satisfied: numpy>=1.15 in /usr/local/lib64/python3.6/site-packages (from matplotlib) (1.19.5)
Requirement already satisfied: six>=1.5 in /usr/lib/python3.6/site-packages (from python-dateutil>=2.1->matplotlib) (1.11.0)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv