I want to do
from PIL import Image
inside a Blender addon. But it throws this error at me:
ModuleNotFoundError: No module named 'PIL'
Thus I've tried to install Pillow via pip like this:
import subprocess
import ensurepip
ensurepip.bootstrap()
pybin = bpy.app.binary_path_python
subprocess.check_call([pybin, '-m', 'pip', 'install', 'Pillow'])
But this doesn't work, either.
What am I doing wrong? :)
pipisn't included on the Linux release builds by default. Might have misunderstood Ray in T71420. In that case it should work with ensurepip, which you would only have to run once. Does it at least find pip after running ensurepip? – Robert Gützkow Mar 19 '20 at 20:48ensurepipchanges nothing. But it seems thatpipis included in the snap version of Blender. But the import error that it can't find PIL persists – Florian Ludewig Mar 20 '20 at 07:07ensurepip.boostrap()and installing the package through subprocess works fine for me. Do you really not get any error message from ensurepip? – Robert Gützkow Mar 20 '20 at 19:27ensurepip.bootstrap()is used followed by a pip install through subprocess, it fails to find a temp directory. This issue occurs on Linux and Windows. – Robert Gützkow Mar 27 '20 at 18:49PIP_REQ_TRACKERif you directly install a package with pip after running ensurepip. – Robert Gützkow Apr 11 '20 at 13:29