you might try to create a virtual environment and install pillow there.
python -m venv ~/myvenv
source ~/myvenv/bin/activate
pip install -U pip
pip install pillow
then use ~/myvenv/bin/python to run the script requiring pillow.
Does this work or do you get the same kind of error message (error: externally-managed-environment
)
I'm no expert concerning the "externally-managed-environment" in fact I read it the first time in your post. But a small search seems to indicate that this is a recent enhancement that tries to avoid conflicts between packages installed with apt and packages installed with pip.
So my suggestion to use a venv doesn't seem that bad.
I read https://itsfoss.com/externally-managed-environment/
and it says amongst many other things:
Ubuntu 23.04, Fedora 38 and probably other recent distribution
versions are implementing this enhancement on the use of Python
packages.
The change has been done to avoid the "conflict between OS package
managers and Python-specific package management tools like pip. These
conflicts include both Python-level API incompatibilities and
conflicts over file ownership."
What are your options?
You can do three things when you try to install a Python package and
see this error.
Install the native package
Create virtual environments in Python
Use Pipx (recommended)
I never tried the option pipx (but I it seems it will also create a virtualenv, + some more automatic stuff) However I think pipx works only for executables and not for libraries, so I'd stick with a vinv or a virtualenv at least utnil pipx is better understood