You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pip error: "The headers or library files could not be found for jpeg" #5042
installing the package properly without the hassle.
What actually happened?
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/72/hplzps2136jc7fy5jf8k4hs00000gn/T/pip-install-o9zi3d_u/pillow/setup.py", line 914, 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
----------------------------------------
ERROR: Failed building wheel for Pillow
What are your OS, Python and Pillow versions?
OS: macOS Big Sur 11.0.1
Python: Python 3.9.0 (default, Nov 14 2020, 10:50:03) [Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Pillow: 8.0.1
I was able to install after a short search engine research
However, this shouldn't be necessary, since Pillow does provide pre-built wheels for macOS: https://pypi.org/project/Pillow/#files (Pillow-8.0.1-cp39-cp39-macosx_10_10_x86_64.whl sounds like the right file)
What version of pip do you have? Does it help to upgrade it?
We also recommend running python3 -m pip install ... (or whatever your python command is) instead of pip install ... to make it explicit which Python you're installing for.
If it doesn't help, please can you post the full verbose output of python3 -m pip install Pillow -v
If you don't want to paste it here, please could you upload it as a zip file or to https://gist.github.com/ or pastebin?
The reason I ask is because it might help us find out why it's not installing a prebuilt binary wheel and is attempting to build from source.
There should be stuff like this, showing in my case that it found Pillow-8.0.1-cp39-cp39-macosx_10_10_x86_64.whl as a potential match, and skipped those for Linux and other Python versions:
...
Skipping link: none of the wheel's tags match: cp38-cp38-manylinux2014_aarch64: https://files.pythonhosted.org/packages/c0/77/ca05a9365fc72252522c1b6a6cc1f579cb5791e824480c6499b789f5a988/Pillow-8.0.1-cp38-cp38-manylinux2014_aarch64.whl#sha256=7c9401e68730d6c4245b8e361d3d13e1035cbc94db86b49dc7da8bec235d0015 (from https://pypi.org/simple/pillow/) (requires-python:>=3.6)
Skipping link: none of the wheel's tags match: cp38-cp38-win32: https://files.pythonhosted.org/packages/f4/8c/45f28efc015ec0040bb6cbde9e763140818388938dd0d2f9e6304322f11f/Pillow-8.0.1-cp38-cp38-win32.whl#sha256=6c1aca8231625115104a06e4389fcd9ec88f0c9befbabd80dc206c35561be271 (from https://pypi.org/simple/pillow/) (requires-python:>=3.6)
Skipping link: none of the wheel's tags match: cp38-cp38-win_amd64: https://files.pythonhosted.org/packages/d2/2c/9ac71068585b3d528349be6617ed963068bfcba3da21018cdb0d2b19f07c/Pillow-8.0.1-cp38-cp38-win_amd64.whl#sha256=cc9ec588c6ef3a1325fa032ec14d97b7309db493782ea8c304666fb10c3bd9a7 (from https://pypi.org/simple/pillow/) (requires-python:>=3.6)
Found link https://files.pythonhosted.org/packages/b2/a2/5a1924e8af7e197c277127be7682a2491d7c1a144b008dd40830f6567bfb/Pillow-8.0.1-cp39-cp39-macosx_10_10_x86_64.whl#sha256=eb472586374dc66b31e36e14720747595c2b265ae962987261f044e5cce644b5 (from https://pypi.org/simple/pillow/) (requires-python:>=3.6), version: 8.0.1
Skipping link: none of the wheel's tags match: cp39-cp39-manylinux1_i686: https://files.pythonhosted.org/packages/c5/a1/c922dedd3c075431395a1672413f891a5921988a7bab2c1088ff57a5897f/Pillow-8.0.1-cp39-cp39-manylinux1_i686.whl#sha256=0eeeae397e5a79dc088d8297a4c2c6f901f8fb30db47795113a4a605d0f1e5ce (from https://pypi.org/simple/pillow/) (requires-python:>=3.6)
...
PIP installs package but Image module fails without libjpeg
....
from PIL import Image
File "/usr/local/lib/python3.9/site-packages/PIL/Image.py", line 94, in <module>
from . import _imaging as core
ImportError: dlopen(/usr/local/lib/python3.9/site-packages/PIL/_imaging.cpython-39-darwin.so, 2): Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.9.dylib
Referenced from: /usr/local/lib/python3.9/site-packages/PIL/_imaging.cpython-39-darwin.so
Reason: image not found
Please don’t be rude to the developers trying to help you on a platform released within the last week.
Reacted by Jeffrey 'Alex' Clark, Oisín Byrne, samgalam, chuck00lin, Zmeev Viktor, Alexander Dedunovich, Hoe Jiun Tian, Brandon Slaght, darien bryant, Sofiane S and 10 more
python-pillow/pillow-team Maybe we just need to leave one of these "headers or library files" issues opened permanently … and then paste in links to other more relevant issues … e.g. "wheels for M1 macs" ?
I think that was one of the inspirations for the new Discussions feature, as in most cases installation is not really an "issue" in Pillow (although it is in some cases).
@python-pillow/pillow-team Maybe we just need to leave one of these "headers or library files" issues opened permanently … and then paste in links to other more relevant issues … e.g. "wheels for M1 macs" ?
We could try that, and maybe lock and pin it, but I think people often find other issues via search. The M1 issue is currently 3rd in the issue list, so not that hard to find if browsing, not searching. I'll pin that too. And we probably will need some M1 changes for the next release.
MacOS Big Sur 11.2.3
MacBook Pro (16-inch, 2019)
2.4 GHz 8-Core Intel Core i9
python -m pip install --upgrade pip in venv solves the issue for me.
Thanks to everyone who participated in this thread ❤️
Reacted by Siddarth Wekhande, Joel Rorseth, Guillermo Gilpérez Alcázar, Ebrahim Ebrahim, jessebrennan, gredin, Spencer Grossarth and Carlos Andrés Sánchez Venegas
writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
running build_ext
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-install-upaphstl/pillow_137a411b2c1640fc9ddca2e4fb5e49f0/setup.py", line 1024, in <module>
zip_safe=not (debug_build() or PLATFORM_MINGW),
File "/opt/_internal/cpython-3.6.15/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/opt/_internal/cpython-3.6.15/lib/python3.6/site-packages/setuptools/command/install.py", line 68, in run
return orig.install.run(self)
File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/command/install.py", line 545, in run
self.run_command('build')
File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/opt/_internal/cpython-3.6.15/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 79, in run
_build_ext.run(self)
File "/opt/_internal/cpython-3.6.15/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/tmp/pip-install-upaphstl/pillow_137a411b2c1640fc9ddca2e4fb5e49f0/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-install-upaphstl/pillow_137a411b2c1640fc9ddca2e4fb5e49f0/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
----------------------------------------
ERROR: Command errored out with exit status 1: /opt/_internal/cpython-3.6.15/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-upaphstl/pillow_137a411b2c1640fc9ddca2e4fb5e49f0/setup.py'"'"'; __file__='"'"'/tmp/pip-install-upaphstl/pillow_137a411b2c1640fc9ddca2e4fb5e49f0/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-vdxsr3c1/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-gcizpx28/overlay --compile --install-headers /tmp/pip-build-env-gcizpx28/overlay/include/python3.6m/pillow Check the logs for full command output.
----------------------------------------
WARNING: Discarding file:///github/workspace. Command errored out with exit status 1: /opt/_internal/cpython-3.6.15/bin/python /opt/_internal/cpython-3.6.15/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-gcizpx28/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel 'cython>0.26' numpy Polygon3 'datastock>=0.0.20' Check the logs for full command output.
ERROR: Command errored out with exit status 1: /opt/_internal/cpython-3.6.15/bin/python /opt/_internal/cpython-3.6.15/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-gcizpx28/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel 'cython>0.26' numpy Polygon3 'datastock>=0.0.20' Check the logs for full command output.
+ echo 'Building wheels failed.'
+ exit 1
Building wheels failed.
0s
0s
0s
@nulano , any idea how to fix it for github Actions ? This is preventing me from releasing a new version...
Activity
nulano commentedon Nov 15, 2020
These libraries are listed in the macOS installation from source instructions linked in the error message: https://pillow.readthedocs.io/en/stable/installation.html#building-on-macos
However, this shouldn't be necessary, since Pillow does provide pre-built wheels for macOS: https://pypi.org/project/Pillow/#files (
Pillow-8.0.1-cp39-cp39-macosx_10_10_x86_64.whlsounds like the right file)Are you using one of the new Apple Silicon Macs?
setanarut commentedon Nov 16, 2020
No, macbook pro 2016 intel i7
setanarut commentedon Nov 16, 2020
It's a packaging issue, I'm not sure if the PIP or Pillow is to blame. both are responsible.
hugovk commentedon Nov 16, 2020
What version of pip do you have? Does it help to upgrade it?
We also recommend running
python3 -m pip install ...(or whatever yourpythoncommand is) instead ofpip install ...to make it explicit which Python you're installing for.If it doesn't help, please can you post the full verbose output of
python3 -m pip install Pillow -vsetanarut commentedon Nov 16, 2020
@hugovk- Big sur clean installation, everything is the latest version. Latest python3 installed with brew.
brew install python3brew link python3pip3 install PillowUsing pip 20.2.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
hugovk commentedon Nov 16, 2020
Thanks, what do you get when running this?
setanarut commentedon Nov 16, 2020
brew uninstall libjpegpip3 uninstall Pillowpython3 -m pip install Pillow -vI got 683 KB, 1986 lines output. I don't want to paste it here.
Last two lines;
hugovk commentedon Nov 16, 2020
If you don't want to paste it here, please could you upload it as a zip file or to https://gist.github.com/ or pastebin?
The reason I ask is because it might help us find out why it's not installing a prebuilt binary wheel and is attempting to build from source.
There should be stuff like this, showing in my case that it found
Pillow-8.0.1-cp39-cp39-macosx_10_10_x86_64.whlas a potential match, and skipped those for Linux and other Python versions:But wait!
Looks like it's working now?
setanarut commentedon Nov 16, 2020
PIP installs package but Image module fails without
libjpegsetanarut commentedon Nov 16, 2020
hugovk commentedon Nov 16, 2020
https://pillow.readthedocs.io/en/stable/installation.html#building-from-source
setanarut commentedon Nov 16, 2020
libjpeg is not the default in the operating system, but the default for Pillow. I hate ad hominem developers.
wiredfool commentedon Nov 16, 2020
Please don’t be rude to the developers trying to help you on a platform released within the last week.
13 remaining items
nulano commentedon Dec 16, 2020
I think that was one of the inspirations for the new Discussions feature, as in most cases installation is not really an "issue" in Pillow (although it is in some cases).
hugovk commentedon Dec 16, 2020
#5093 is for the new M1 Macs, please can you try the suggestions at #5093 (comment)?
hugovk commentedon Dec 16, 2020
We could try that, and maybe lock and pin it, but I think people often find other issues via search. The M1 issue is currently 3rd in the issue list, so not that hard to find if browsing, not searching. I'll pin that too. And we probably will need some M1 changes for the next release.
bschollnick commentedon Jan 4, 2021
Bobronium commentedon Feb 15, 2021
I have the same issue: Python 3.9, Big Sur, Intel.
@hugovk, here's output.txt
After running
it got installed, however, produced an error:
If I switch back to Python 3.8 it installs and works flawlessly. Any suggestions how to fix it on 3.9?
Solution
turns out I had old pip version in my venv, updating it solved the issue.
hongquanvn1998 commentedon Feb 18, 2021
nice. It's work for my Mac M1
baijifeilong commentedon Feb 20, 2021
apt install libjpegfor ubuntup-hebert commentedon Apr 7, 2021
Brand new Macbook off the shelf:
MacOS Big Sur 11.2.3
MacBook Pro (16-inch, 2019)
2.4 GHz 8-Core Intel Core i9
python -m pip install --upgrade pipin venv solves the issue for me.Thanks to everyone who participated in this thread ❤️
thewolfcommander commentedon Jun 20, 2021
That works for me too... MacBook air M1 2020. Give it a try. Trust me
chrisdlangton commentedon Nov 15, 2021
on alpine I had to run
apk update && apk upgrade && apk add --no-cache freetype-dev libpng-dev jpeg-dev libjpeg-turbo-devggilperez commentedon Nov 27, 2021
This works for me, MacBook Air M1 2020, thanks.
dinkopehar commentedon Oct 3, 2022
On MacOS Montery, installing
jpeg-turbosolved a problem forPillow==8.0.0.Didou09 commentedon Oct 17, 2022
Fails for me during my Github Action workflow to build the wheel of my library:
https://github.com/ToFuProject/tofu/actions/runs/3265080608/jobs/5366784038
@nulano , any idea how to fix it for github Actions ? This is preventing me from releasing a new version...
hugovk commentedon Oct 17, 2022
@Didou09 If building from source, make sure you have the non-Python dependencies installed. See https://pillow.readthedocs.io/en/stable/installation.html#building-from-source
If that doesn't help, please create a new issue. (And we no longer support Python 3.6, it's EOL since last year.)