ESPHome can not find pillow

Hi, I am using ESPHome with Home Assistant, no problem. I have just added a display to my project and added font , display and i2c tot he YAML file. However, when running I get:

"Please install the pillow python package to use this feature. (pip install pillow).

  • file: font/monofont.ttf
    id: opensans
    size: 10"

The file does exist at the specified location.

I have added pillow, and can use it using python and python3:

>>> from PIL import Image
>>> im = Image.open("font/a.png")
>>> im.show()

It shows the image.

So the question is, what exactly is ESPHome looking for to satisfy itself that pillow is installed?

Python is 3.6.15
ESPHome is 2022.10.2
OSX 10.14.6

Thanks.

How are you running EspHome? The addon, a docker container or natively?

Manual install on OS X - Installing ESPHome Manually — ESPHome

Invoking via command line, and also using the dashboard. Same result.

Installed ESPHome on a Win 10 machine, and my display is working just fine. Looks like this is specific to my mac setup. I will re-visit at some point.

I’m seeing the same behavior in the web based Studio Code Server. Projects that do not use a font or an image compile and OTA fine, project that do have fonts or images fail to compile with an error like this:

Failed config

font: [source esphome/blast-gate-01.yaml:46]
  
  Please install the pillow python package to use this feature. (pip install pillow).
  - file: gfonts://Roboto
    id: roboto_20
    size: 20
  
  Please install the pillow python package to use this feature. (pip install pillow).
  - file: gfonts://Roboto
    id: roboto_24
    size: 24

System details

Home Assistant 2023.2.2
Supervisor 2023.01.1
Operating System 9.5
Frontend 20230202.0 - latest


Add-on: Studio Code Server
Fully featured Visual Studio Code (VSCode) experience integrated in the Home Assistant frontend.
Add-on version: 5.5.2
You are running the latest version of this add-on.
System: Home Assistant OS 9.5 (amd64 / qemux86-64)
Home Assistant Core: 2023.1.7
Home Assistant Supervisor: 2023.01.1


Add-on: ESPHome
ESPHome add-on for intelligently managing all your ESP8266/ESP32 devices
Add-on version: 2022.12.8
You are running the latest version of this add-on.
System: Home Assistant OS 9.5 (amd64 / qemux86-64)
Home Assistant Core: 2023.2.2
Home Assistant Supervisor: 2023.01.1

From what I can see Pillow is in the esphome addon container.

From what Studio Code Server can see, it isn’t. Is there some way to make Studio Code Server see that it’s available in the esphome container?

Are you using studio code server to edit your esphome yamls? Never done that.

To see if you do have pillow in your container enter the container and look via pip3

docker exec -it addon_15ef4d2f_esphome bash
pip3 list|grep -i pillow
1 Like

I’m using the dashboard editor which is fine but VSCode would be better. I’d like to use my normal Windows install of VSCode w/ ESPhome extension but the same problem happens when I use Code Server, which I figured made for a better bug report as it’s bit more of a known and managed entity.

# docker exec -it addon_5c53de3b_esphome bash
root@5c53de3b-esphome:/# pip3 list|grep -i pillow
Pillow                8.1.2

Here’s a more complete log if it is of any help

 *  Executing task: esphome run esphome/aq-sensor-02.yaml --device OTA 

INFO Reading configuration esphome/aq-sensor-02.yaml...
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO0 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
Failed config

font: [source esphome/aq-sensor-02.yaml:554]
  
  Please install the pillow python package to use this feature. (pip install pillow).
  - file: gfonts://Roboto
    id: font_roboto_16
    size: 16

 *  The terminal process "/usr/bin/zsh '-c', 'esphome run esphome/aq-sensor-02.yaml --device OTA'" terminated with exit code: 2. 
 *  Terminal will be reused by tasks, press any key to close it. 

Wondering if maybe it needs to be in the Studio Code Server container I checked there to find pip3 is completely broken:

root@a0d7b954-vscode:/# pip3
Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 5, in <module>
    from pip._internal.cli.main import main
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/cli/main.py", line 9, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/cli/main_parser.py", line 9, in <module>
    from pip._internal.build_env import get_runnable_pip
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/build_env.py", line 20, in <module>
    from pip._internal.cli.spinners import open_spinner
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/cli/spinners.py", line 9, in <module>
    from pip._internal.utils.logging import get_indentation
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/utils/logging.py", line 29, in <module>
    from pip._internal.utils.misc import ensure_dir
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/utils/misc.py", line 42, in <module>
    from pip._internal.locations import get_major_minor_version
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/locations/__init__.py", line 67, in <module>
    from . import _distutils
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/locations/_distutils.py", line 20, in <module>
    from distutils.cmd import Command as DistutilsCommand
ModuleNotFoundError: No module named 'distutils.cmd'

Allright, Got a working solution! Thanks to @nickrout for helping out and poking me into action :smiley:

  1. Settings > Add-Ons > Studio Code Server > Configuration
  2. Hit the menu, Edit in YAML
  3. Paste in the following to install pip and then install pillow
init_commands:
  - pip install pillow
packages:
  - python3-pip

And now the ESPhome extension in Studio Code Server can be configured and run to compile and then OTA install your ESPhome devices.

3 Likes