Installed python dependencies location

I have question wrt how the python dependencies are managed in home assistant.

I did find:

I also understood that for custom components, they’d define their requirements in a manifest.json file, which then can be used by the core home assistant service to install the required dependencies. Before that’d be in that /config/deps folder, but I’m not so sure about that anymore.

The practical issue I’m facing is that I use a 3rd party custom component which used to work OK, but since a recent update (2022.07.3) it complains about one of those dependencies from the custom component no longer being there (https://github.com/ollo69/ha-smartthinq-sensors/issues/353 for more details).

At this point, I figure the issue is not so much the custom component but more the behavior of home assistant and the dependencies.

My specific setup uses the containerized home assistant core version + https://k3s.io/ for managing the containers. The only folder which is retained between container switches is the /config folder, which means that it works OK if the dependencies are kept in /config/deps, but not if they’d be installed into another folder.

Are there any documented details about how dependencies for custom components are supposed to work?

1 Like

Any word on this? I am facing the same issue. It seems that HA is not installing the requirements that I have specified in my manifest.json. It was working fine up until the last HA Core update, and now it’s back to this error - frustrating!

System Log:

2023-10-25 13:16:50.438 ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration soundtouchplus: Unable to import component: cannot import name 'WebSocketApp' from 'websocket' (/usr/local/lib/python3.11/site-packages/websocket/__init__.py)
File "/config/custom_components/soundtouchplus/__init__.py", line 9, in <module>
2023-10-25 13:16:51.536 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading flow for integration soundtouchplus: cannot import name 'WebSocketApp' from 'websocket' (/usr/local/lib/python3.11/site-packages/websocket/__init__.py)
2023-10-25 13:16:51.537 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading flow for integration soundtouchplus: cannot import name 'WebSocketApp' from 'websocket' (/usr/local/lib/python3.11/site-packages/websocket/__init__.py)
File "/config/custom_components/soundtouchplus/__init__.py", line 9, in <module>

manifest.json

{
  ...
  "requirements": [
    "websocket-client==0.53.0",
    "websocket",
    "rel",
    "urllib3",
    "smartinspectPython>=3.0.26",
    "bosesoundtouchapi==1.0.0rc40"
  ],
...
}

It’s been a long time since I did look into this issue so I don’t fully recall what the exact issue was.

I think there was also a change with the specific custom integration I was using that required me to reauthorize – basically not really an issue in HA itself.

I think it might be the websocket entry in your manifest.json. there is a websocket library on pypi which i do not think you should be installing and this is maybe causing a conflict with the websocket-client which is what your integration is expecing when importing WebSocketApp.

You will need to remove the websocket entry but also uninstall that library in your HA environment.

Thanks Mark, I appreciate the direction.

I’m fairly new to the websocket library, learning Python, and learning HA as well. I thought I had read somewhere that the “websocket” library was required if using “websocket-client”. To be honest, I have tried so many different things to fix this that I’m wondering which way is up! :smiley:

I will give your suggestion a try, and let you know how it goes.

Thank you - Todd

Hi Mark. Just wanted to let you (and future readers) know that the addition of “websocket” was the problem when trying to use “websocket-client”. I removed the “websocket” entry from requirements, and it is now working like a charm.

Thanks again for pointing me in the right direction.

Great to hear. Can you mark as solution. Thx