Closed bryankaplan closed 4 months ago
Have you tried the void linux binary ?
ipython
may not be using your local venv
. Try pip install ipython
after activating your environment.
I reckon I'm probably missing a dependency, but I don't know what. I've tried installing freetype-devel
If you're installing from source (which you are, since you used --no-binary :all:
), then yes, you need freetype-devel. But that should be the only dependency you need for fonts if void linux is at all reasonable (which I assume it is).
ipython
may not be using your localvenv
. Trypip install ipython
after activating your environment.
Good point. @bryankaplan Does running the following produce the same output as your python3 -m PIL --report
above?
from PIL import features
features.pilinfo()
Have you tried the void linux binary ?
@aclark4life That's v10.4, and I need 9.5.
ipython may not be using your local venv. Try pip install ipython after activating your environment.
@Yay295 Yes, it is. This code was extracted from the larger project to demonstrate the problem. But I tried installing ipython in the venv, just to be sure, and indeed the ImportError
is identical.
Does running the following produce the same output as your python3 -m PIL --report above?
@nulano They're 100% identical. (I diff
'd the output.)
Ok, I've managed to reproduce in a Docker container.
You probably tried to install Pillow before installing freetype-devel, which didn't work:
$ docker pull ghcr.io/void-linux/void-glibc-full
$ docker run --rm -it ghcr.io/void-linux/void-glibc-full
# xbps-install -Su
[...]
# xbps-install gcc python3-devel libjpeg-turbo-devel zlib-devel freetype-devel
[...]
# python -m venv venv
# . ./venv/bin/activate
(venv) # pip install pillow==9.5.0 --no-binary :all:
[...]
(venv) # python -c "from PIL import _imagingft; print(_imagingft.freetype2_version)"
ImportError: cannot import name '_imagingft' from 'PIL' (/venv/lib/python3.12/site-packages/PIL/__init__.py)
Even if you then install freetype-devel and try to install Pillow in a new venv, it will use a cached wheel:
(venv) # deactivate
# xbps-install freetype-devel
[...]
# python -m venv venv2
# . ./venv2/bin/activate
(venv2) # pip install pillow==9.5.0 --no-binary :all:
Collecting pillow==9.5.0
Using cached Pillow-9.5.0-cp312-cp312-linux_x86_64.whl
Installing collected packages: pillow
Successfully installed pillow-9.5.0
(venv2) # python -c "from PIL import _imagingft; print(_imagingft.freetype2_version)"
ImportError: cannot import name '_imagingft' from 'PIL' (/venv/lib/python3.12/site-packages/PIL/__init__.py)
You have to add a parameter to pip to ask it to ignore the cached wheel (--no-cache-dir Pillow
), or just remove the wheel from cache with pip cache remove Pillow
:
(venv2) # deactivate
# python -m venv venv3
# . ./venv3/bin/activate
(venv3) # pip cache remove Pillow
(venv3) # pip install pillow==9.5.0 --no-binary :all:
[...]
(venv3) # python -c "from PIL import _imagingft; print(_imagingft.freetype2_version)"
2.13.2
Does that help?
@nulano Thank you! I knew as soon as I started reading your thought that it was probably the answer, and I started typing this response before the test was complete. Test succeeded. Thank you so much!
Goal
Ultimately I'm trying to run detectron2. I've isolated the Pillow problem separate from detectron2, but that goal impacts my installation, as noted below.
Steps to Reproduce
On Void Linux:
Whoa, what's up with that
pip install
line?--no-binary :all:
based on advice given in #7949.Expected Result
_imagingft
is successfully imported.Observed Result
ImportError: cannot import name '_imagingft' from 'PIL'
OS, Python and Pillow versions
python3 -m PIL --report
output:Done, above.
Thoughts
I reckon I'm probably missing a dependency, but I don't know what. I've tried installing
freetype-devel
,libjpeg-turbo-devel
, andlibraqm-devel
to no avail.