Migrating to Container - Custom Components Python Issue

Today I took the plunge to finally move from pyenv over to a Docker container with my configuration due to soon to be deprecation. I moved my whole configuration over to the docker directory and everything seems to be up and running fine with some tweaks.

However, I had some trouble fixing Alexa Media Player and Spotify Plus with some Python errors:

Setup failed for custom integration 'alexa_media': Requirements for alexa_media not found: ['alexapy==1.29.9']. 
Setup failed for custom integration 'spotifyplus': Requirements for spotifyplus not found: ['smartinspectpython>=3.0.38', 'spotifywebapipython>=1.0.254'].

......failed to create directory `/usr/local/lib/python3.13......

I tried adding the following to my docker-compose.yml

    environment:
      - PIP_TARGET=/config/deps
      - PYTHONPATH=/config/deps
      - PIP_NO_CACHE_DIR=1

However, it made no difference. They wouldn’t come up until I manually went in and added these libraries to pip

docker exec -it homeassistant bash

pip install -t /config/deps --no-deps alexapy==1.29.9 &&
pip install -t /config/deps --no-deps smartinspectpython==3.0.38 &&
pip install -t /config/deps --no-deps spotifywebapipython==1.0.254
pip install -t /config/deps --no-deps authcaptureproxy==1.3.3
pip install -t /config/deps --no-deps typer==0.12.5 click==8.1.7 shellingham==1.5.4 rich==10.16.2

exit

Any reason I would need to go in and manually add these? Perhaps if I re-installed the custom component now in the container? Trying to understand what the deal was and why it wouldn’t respect and use the ENV variable directory defined and created within the container.

Where do those custom component come from? HACS or somewhere else?
Normally a docker image is indeed ‘clean’ of anything custom, so specific libraries would need to be provided/installed at install time.
So depending on how you installed them in venv, custom component install need to be redone and possibly everytime you do a docker image update.
Also possible, is that the libraries get placed by the custom componentn in /config/custom_components , that would be the most workable way for docker deployment (as in , the libs would remain during image updates)

Yeah these were just natively installed with HACS. If I come into this again I’ll try doing a reinstall or something through HACS. I would be surprised if people using Docker + HACS would have to do this song and dance on every Home Assistant update.

SpotifyPlus integration component author here; I am also the author of the spotifywebapipython and smartinspectpython packages …

The SpotifyPlus Integration has the following in the manifest.json file for requirements; I believe this only applies if the component is installed via HACS though:

  "requirements": [
    "numpy>=2.3.2",
    "oauthlib>=3.2.2",
    "pillow>=11.3.0",
    "platformdirs>=4.1.0",
    "requests>=2.31.0",
    "requests_oauthlib>=1.3.1",
    "smartinspectpython>=3.0.38",
    "spotifywebapipython>=1.0.254",
    "urllib3>=2.0",
    "zeroconf>=0.132.2"
  ],

The following are also listed in the SpotifyPlus integration requirements.txt file, which is not used by HACS, but is used by various Python development environments (Visual Studio, VSCode, etc):

pip>=21.0,<23.4
homeassistant==2025.7.1
pillow>=11.3.0,
ruff>=0.1.3
smartinspectpython>=3.0.38
spotifywebapipython>=1.0.254
urllib3>=2.0

I assume you would need to keep track of these requirements manually (or parse the contents of the manifest.json / requirements.txt) since you are not installing the SpotifyPlus integration via the HACS installer. Note that the SpotifyPlus integration is not a python package (just code), as there is no setup.py module like a python package would have that contains listed requirements.

Also note that by issuing a pip install spotifywebapipython>=1.0.254 that it would install the smartinspectpython>=3.0.38 package requirement, as that module is in the setup.py requirements for spotifywebapipython package.

Hope it helps!

Hey Todd, good to run into you again. These were integrations that I installed directly through HACS when I was running HA core through pyenv which then I just transitioned over to a HA docker container.

Perhaps if this comes up again after a Home Assistant update, I can try removing and reinstalling again through HACS and see what happens now that it’s within the container. I assume every-time people who use HACS as well as do a Home Assistant update to their containers shouldn’t have to go manually into the container and install the dependencies with pip manually, no?

My 2cts, if you want to install packages that are not part of HA or a custom app, then you can use pyscript. In my config/pyscript folder I maintain a requirments.txt with a few (only a few)

@kentoe
Not sure on that one, as I have never done anything with HA Docker containers directly. I have always just used HA Core.

If you installed the SpotifyPlus integration directly through HACS, then HACS should have picked up the requirements via manifest.json; not sure why that didn’t work. It would make sense though if you just moved the configuration from pyenv directly to the docker container, as the pyenv environment DOES contain the packages, but the docker environment does not since they were not installed in that environment yet… This can be proven by uninstalling the integration in the Docker container, and re-installing it via HACS - it should work I would think.

FYI, I just released another integration update yesterday, along with spotifywebapipython version 1.0.255. I would be interested in knowing if the update fails, since the integration has a manifest.json requirement of spotifywebapipython>=1.0.255.

Standard update mechanism looked like it worked fine. However, upon rebooting I got:

Unable to install package spotifywebapipython>=1.0.255: error: failed to remove file /usr/local/lib/python3.13/site-packages/xmltodict-0.13.0.dist-info/INSTALLER: Permission denied (os error 13)

Setup failed for custom integration ‘spotifyplus’: Requirements for spotifyplus not found: [‘spotifywebapipython>=1.0.255’].

I went back to HACS and did a removal of the integration. Then re-installed and got the same:

Setup failed for custom integration ‘spotifyplus’: Requirements for spotifyplus not found: [‘spotifywebapipython>=1.0.255’].

Unable to install package spotifywebapipython>=1.0.255: error: failed to remove file /usr/local/lib/python3.13/site-packages/xmltodict-0.13.0.dist-info/INSTALLER: Permission denied (os error 13)

It looks like similiar issues others have encountered here:

I’ll reach out in that thread and see what others suggest post conversion.

1 Like

Okay, so apparently according to the Github Baloob said:

Container is only supported to be run as root as per our architecture discussion record: architecture/adr/0013-home-assistant-container.md at dc73ba483c912f1294e27972f5beeebf575ac9ba · home-assistant/architecture · GitHub. This issue will be closed.

So I removed my user: line in my docker-compose.yml and now it seems things are working as expected! Sorry for the confusion and wasting your time @thlucas

1 Like