core icon indicating copy to clipboard operation
core copied to clipboard

module 'urllib3.util' has no attribute 'PROTOCOL_TLS'

Open dawiinci opened this issue 1 year ago • 18 comments

The problem

After updating to 2023.6.3 I got this error which made the cloud component unavailable. After a restart it works properly. module 'urllib3.util' has no attribute 'PROTOCOL_TLS' Multiple errors regarding urllib3 appear and no cloud based services work.

I think this might be related:

https://github.com/home-assistant/core/issues/94722

What version of Home Assistant Core has the issue?

2023.6.3

What was the last working version of Home Assistant Core?

2023.5.7

What type of installation are you running?

Home Assistant Core

Integration causing the issue

cloud

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Installation runs on M1 Mac. Python is 3.11

Additional information

No response

dawiinci avatar Jun 25 '23 11:06 dawiinci

I have the same behavior on a fresh install of Home Assistant core 2023.6.3 on Linux only with Python 3.11

pyenv install 3.11.4
pyenv virtualenv 3.11.4 ha_2023.6.3
pyenv activate ha_2023.6.3
pip install wheel
pip install homeassistant==2023.6.3
hass

and this is the log

2023-06-26 17:46:33.614 INFO (SyncWorker_2) [homeassistant.util.package] Attempting install of PyNaCl==1.5.0
2023-06-26 17:46:33.635 INFO (MainThread) [homeassistant.setup] Setup of domain tts took 0.0 seconds
2023-06-26 17:46:33.680 INFO (MainThread) [homeassistant.setup] Setting up assist_pipeline
2023-06-26 17:46:33.698 INFO (MainThread) [homeassistant.setup] Setup of domain assist_pipeline took 0.0 seconds
2023-06-26 17:46:35.149 INFO (SyncWorker_1) [homeassistant.util.package] Attempting install of aioesphomeapi==13.9.0
2023-06-26 17:46:35.154 INFO (SyncWorker_0) [homeassistant.loader] Loaded notify from homeassistant.components.notify
2023-06-26 17:46:35.158 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing component homeassistant.components.mobile_app
Traceback (most recent call last):
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/homeassistant/loader.py", line 813, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassi/.pyenv/versions/3.11.4/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/homeassistant/components/mobile_app/__init__.py", line 5, in <module>
    from homeassistant.components import cloud, notify as hass_notify
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/homeassistant/components/cloud/__init__.py", line 9, in <module>
    from hass_nabucasa import Cloud
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/hass_nabucasa/__init__.py", line 15, in <module>
    from .auth import CloudError, CognitoAuth
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/hass_nabucasa/auth.py", line 11, in <module>
    import boto3
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/boto3/__init__.py", line 17, in <module>
    from boto3.session import Session
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/botocore/session.py", line 26, in <module>
    import botocore.client
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/botocore/client.py", line 15, in <module>
    from botocore import waiter, xform_name
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/botocore/waiter.py", line 18, in <module>
    from botocore.docs.docstring import WaiterDocstring
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/botocore/docs/__init__.py", line 15, in <module>
    from botocore.docs.service import ServiceDocumenter
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/botocore/docs/service.py", line 14, in <module>
    from botocore.docs.client import ClientDocumenter, ClientExceptionsDocumenter
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/botocore/docs/client.py", line 17, in <module>
    from botocore.docs.example import ResponseExampleDocumenter
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/botocore/docs/example.py", line 13, in <module>
    from botocore.docs.shape import ShapeDocumenter
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/botocore/docs/shape.py", line 19, in <module>
    from botocore.utils import is_json_value_header
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/botocore/utils.py", line 37, in <module>
    import botocore.httpsession
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/botocore/httpsession.py", line 45, in <module>
    from urllib3.contrib.pyopenssl import (
  File "/home/homeassi/.pyenv/versions/3.11.4/envs/ha_2023.6.3/lib/python3.11/site-packages/urllib3/contrib/pyopenssl.py", line 97, in <module>
    util.PROTOCOL_TLS: OpenSSL.SSL.SSLv23_METHOD,
    ^^^^^^^^^^^^^^^^^
AttributeError: module 'urllib3.util' has no attribute 'PROTOCOL_TLS'
2023-06-26 17:46:35.164 ERROR (MainThread) [homeassistant.setup] Setup failed for mobile_app: Unable to import component: Exception importing homeassistant.components.mobile_app
2023-06-26 17:46:35.165 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of default_config. Setup failed for dependencies: cloud, mobile_app
2023-06-26 17:46:35.165 ERROR (MainThread) [homeassistant.setup] Setup failed for default_config: (DependencyError(...), 'Could not setup dependencies: cloud, mobile_app')

droscy avatar Jun 26 '23 15:06 droscy

Upgrading urllib3 from 1.26.16 to 2.0.3 ~~solve this issue~~. pip install --upgrade urllib3

cheadrian avatar Jun 29 '23 06:06 cheadrian

Unfortunately urllib3>=1.27 is incompatible with botocore (even latest version).

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed.
This behaviour is the source of the following dependency conflicts.
botocore 1.29.160 requires urllib3<1.27,>=1.25.4, but you have urllib3 2.0.3 which is incompatible.

droscy avatar Jun 29 '23 07:06 droscy

I have also encountered the same problem when running the hass 2023.6.3 version on Termux with aarch64. Python 3.11.4.

JackTvT avatar Jun 30 '23 03:06 JackTvT

After installing botocore from source: pip install git+https://github.com/boto/botocore and going back to urlib3-1.26.16, i don't get that error anymore. Python 3.10.12, homeassistant-2023.6.3, botocore-1.29.164, urllib3-1.26.16.

cheadrian avatar Jun 30 '23 07:06 cheadrian

Also had this issue

Python 3.11.4 HASS 2023.7.1

Ended up doing @cheadrian's suggestion for: pip install git+https://github.com/boto/botocore and restarting HASS and loads fine now.

rwarner avatar Jul 10 '23 15:07 rwarner

I just ran into this issue when upgrading Home Assistant core in docker from 2023.6.2 to 2023.7.3.

I was able to fix it by installing the missing dependency and restarting the container:

docker exec -it hass pip install git+https://github.com/boto/botocore
docker restart hass

It seems that 2023.7 still has broken dependencies with the recent python upgrades.

lanrat avatar Jul 25 '23 18:07 lanrat

Can confirm this issue on a development install (2023.8) with Python 3.11.3. The reported fix works: pip install git+https://github.com/boto/botocore

synesthesiam avatar Jul 26 '23 13:07 synesthesiam

Just updated to Python 3.11.5 and HA core 2023.8.4 and can confirm the same fix works as well.

dshokouhi avatar Aug 24 '23 19:08 dshokouhi

Upgraded to Debian Bookworm (Python 3.11.2) and installed homeassistant-core 2023.9.2 and also ran into this problem. pip3 install git+https://github.com/boto/botocore under the homeassistant venv worked also here.

Millnert avatar Sep 20 '23 22:09 Millnert

Upgraded to Debian Bookworm (Python 3.11.2) and installed homeassistant-core 2023.9.2 and also ran into this problem. pip3 install git+https://github.com/boto/botocore under the homeassistant venv worked also here.

Confirmed also from my side - upgraded to debian bookworm, upgraded venv, upgraded homeassistant and had to use the above fix with the botocore version .

redcastle-de avatar Sep 25 '23 13:09 redcastle-de

Alternative workaround: since the module is "only" needed by the dependencies cloud and mobile_app, you can replace the default_config: line in configuration.yaml with a list that doesn't include those if they aren't needed in your setup (eg. when using Tailscale and HomeKit bridge instead of the first-party remote connectivity and mobile app, or when only using web browsers while connected to the same LAN).

I've based the below configuration.yaml on the defaults listed here: https://www.home-assistant.io/integrations/default_config/

Replacement configuration.yaml

I've commented out default_config as well as the ones already listed below it.

# Loads default set of integrations. Do not remove.
#default_config:
#automation:
assist_pipeline:
backup:
bluetooth:
config:
conversation:
counter:
dhcp:
energy:
#frontend:
hardware:
history:
homeassistant_alerts:
image_upload:
input_boolean:
input_button:
input_datetime:
input_number:
input_select:
input_text:
logbook:
logger:
map:
my:
network:
person:
schedule:
#scene:
#script:
stream:
sun:
system_health:
tag:
timer:
usb:
webhook:
zone:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

introt avatar Oct 15 '23 13:10 introt

Applied the fix pip3 install git+https://github.com/boto/botocore under venv and then run hass, under debian12/raspi 3, ha core 2023.8.4, there is still the issue. urllib3 installed is 1.26.18, and in python interactive mode, from urllib3.util import PROTOCOL_TLS does not trigger any error.

logs:

(homeassistant) homeassistant@rpi3-20230612:/srv/homeassistant$ hass
Unable to find configuration. Creating default one in /home/homeassistant/.homeassistant
2023-10-18 08:23:30.997 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: analytics
2023-10-18 08:24:32.121 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: recorder
2023-10-18 08:44:46.374 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: zeroconf
2023-10-18 08:46:13.823 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: ssdp
2023-10-18 08:46:47.798 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing component homeassistant.components.cloud
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/loader.py", line 813, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/components/cloud/__init__.py", line 9, in <module>
    from hass_nabucasa import Cloud
  File "/srv/homeassistant/lib/python3.11/site-packages/hass_nabucasa/__init__.py", line 15, in <module>
    from .auth import CloudError, CognitoAuth
  File "/srv/homeassistant/lib/python3.11/site-packages/hass_nabucasa/auth.py", line 11, in <module>
    import boto3
  File "/srv/homeassistant/lib/python3.11/site-packages/boto3/__init__.py", line 17, in <module>
    from boto3.session import Session
  File "/srv/homeassistant/lib/python3.11/site-packages/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/session.py", line 26, in <module>
    import botocore.client
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/client.py", line 15, in <module>
    from botocore import waiter, xform_name
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/waiter.py", line 18, in <module>
    from botocore.docs.docstring import WaiterDocstring
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/__init__.py", line 15, in <module>
    from botocore.docs.service import ServiceDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/service.py", line 14, in <module>
    from botocore.docs.client import ClientDocumenter, ClientExceptionsDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/client.py", line 17, in <module>
    from botocore.docs.example import ResponseExampleDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/example.py", line 13, in <module>
    from botocore.docs.shape import ShapeDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/shape.py", line 19, in <module>
    from botocore.utils import is_json_value_header
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/utils.py", line 37, in <module>
    import botocore.httpsession
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/httpsession.py", line 45, in <module>
    from urllib3.contrib.pyopenssl import (
  File "/srv/homeassistant/lib/python3.11/site-packages/urllib3/contrib/pyopenssl.py", line 97, in <module>
    util.PROTOCOL_TLS: OpenSSL.SSL.SSLv23_METHOD,
    ^^^^^^^^^^^^^^^^^
AttributeError: module 'urllib3.util' has no attribute 'PROTOCOL_TLS'
2023-10-18 08:46:47.887 ERROR (MainThread) [homeassistant.setup] Setup failed for cloud: Unable to import component: Exception importing homeassistant.components.cloud
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/loader.py", line 813, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/components/cloud/__init__.py", line 9, in <module>
    from hass_nabucasa import Cloud
  File "/srv/homeassistant/lib/python3.11/site-packages/hass_nabucasa/__init__.py", line 15, in <module>
    from .auth import CloudError, CognitoAuth
  File "/srv/homeassistant/lib/python3.11/site-packages/hass_nabucasa/auth.py", line 11, in <module>
    import boto3
  File "/srv/homeassistant/lib/python3.11/site-packages/boto3/__init__.py", line 17, in <module>
    from boto3.session import Session
  File "/srv/homeassistant/lib/python3.11/site-packages/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/session.py", line 26, in <module>
    import botocore.client
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/client.py", line 15, in <module>
    from botocore import waiter, xform_name
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/waiter.py", line 18, in <module>
    from botocore.docs.docstring import WaiterDocstring
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/__init__.py", line 15, in <module>
    from botocore.docs.service import ServiceDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/service.py", line 14, in <module>
    from botocore.docs.client import ClientDocumenter, ClientExceptionsDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/client.py", line 17, in <module>
    from botocore.docs.example import ResponseExampleDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/example.py", line 13, in <module>
    from botocore.docs.shape import ShapeDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/shape.py", line 19, in <module>
    from botocore.utils import is_json_value_header
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/utils.py", line 37, in <module>
    import botocore.httpsession
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/httpsession.py", line 45, in <module>
    from urllib3.contrib.pyopenssl import (
  File "/srv/homeassistant/lib/python3.11/site-packages/urllib3/contrib/pyopenssl.py", line 97, in <module>
    util.PROTOCOL_TLS: OpenSSL.SSL.SSLv23_METHOD,
    ^^^^^^^^^^^^^^^^^
AttributeError: module 'urllib3.util' has no attribute 'PROTOCOL_TLS'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/setup.py", line 215, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/loader.py", line 821, in get_component
    raise ImportError(f"Exception importing {self.pkg_path}") from err
ImportError: Exception importing homeassistant.components.cloud
2023-10-18 08:48:12.582 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing component homeassistant.components.mobile_app
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/loader.py", line 813, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/components/mobile_app/__init__.py", line 5, in <module>
    from homeassistant.components import cloud, notify as hass_notify
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/components/cloud/__init__.py", line 9, in <module>
    from hass_nabucasa import Cloud
  File "/srv/homeassistant/lib/python3.11/site-packages/hass_nabucasa/__init__.py", line 15, in <module>
    from .auth import CloudError, CognitoAuth
  File "/srv/homeassistant/lib/python3.11/site-packages/hass_nabucasa/auth.py", line 11, in <module>
    import boto3
  File "/srv/homeassistant/lib/python3.11/site-packages/boto3/__init__.py", line 17, in <module>
    from boto3.session import Session
  File "/srv/homeassistant/lib/python3.11/site-packages/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/session.py", line 26, in <module>
    import botocore.client
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/client.py", line 15, in <module>
    from botocore import waiter, xform_name
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/waiter.py", line 18, in <module>
    from botocore.docs.docstring import WaiterDocstring
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/__init__.py", line 15, in <module>
    from botocore.docs.service import ServiceDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/service.py", line 14, in <module>
    from botocore.docs.client import ClientDocumenter, ClientExceptionsDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/client.py", line 17, in <module>
    from botocore.docs.example import ResponseExampleDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/example.py", line 13, in <module>
    from botocore.docs.shape import ShapeDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/shape.py", line 19, in <module>
    from botocore.utils import is_json_value_header
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/utils.py", line 37, in <module>
    import botocore.httpsession
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/httpsession.py", line 45, in <module>
    from urllib3.contrib.pyopenssl import (
  File "/srv/homeassistant/lib/python3.11/site-packages/urllib3/contrib/pyopenssl.py", line 97, in <module>
    util.PROTOCOL_TLS: OpenSSL.SSL.SSLv23_METHOD,
    ^^^^^^^^^^^^^^^^^
AttributeError: module 'urllib3.util' has no attribute 'PROTOCOL_TLS'
2023-10-18 08:48:12.620 ERROR (MainThread) [homeassistant.setup] Setup failed for mobile_app: Unable to import component: Exception importing homeassistant.components.mobile_app
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/loader.py", line 813, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/components/mobile_app/__init__.py", line 5, in <module>
    from homeassistant.components import cloud, notify as hass_notify
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/components/cloud/__init__.py", line 9, in <module>
    from hass_nabucasa import Cloud
  File "/srv/homeassistant/lib/python3.11/site-packages/hass_nabucasa/__init__.py", line 15, in <module>
    from .auth import CloudError, CognitoAuth
  File "/srv/homeassistant/lib/python3.11/site-packages/hass_nabucasa/auth.py", line 11, in <module>
    import boto3
  File "/srv/homeassistant/lib/python3.11/site-packages/boto3/__init__.py", line 17, in <module>
    from boto3.session import Session
  File "/srv/homeassistant/lib/python3.11/site-packages/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/session.py", line 26, in <module>
    import botocore.client
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/client.py", line 15, in <module>
    from botocore import waiter, xform_name
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/waiter.py", line 18, in <module>
    from botocore.docs.docstring import WaiterDocstring
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/__init__.py", line 15, in <module>
    from botocore.docs.service import ServiceDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/service.py", line 14, in <module>
    from botocore.docs.client import ClientDocumenter, ClientExceptionsDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/client.py", line 17, in <module>
    from botocore.docs.example import ResponseExampleDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/example.py", line 13, in <module>
    from botocore.docs.shape import ShapeDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/shape.py", line 19, in <module>
    from botocore.utils import is_json_value_header
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/utils.py", line 37, in <module>
    import botocore.httpsession
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/httpsession.py", line 45, in <module>
    from urllib3.contrib.pyopenssl import (
  File "/srv/homeassistant/lib/python3.11/site-packages/urllib3/contrib/pyopenssl.py", line 97, in <module>
    util.PROTOCOL_TLS: OpenSSL.SSL.SSLv23_METHOD,
    ^^^^^^^^^^^^^^^^^
AttributeError: module 'urllib3.util' has no attribute 'PROTOCOL_TLS'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/setup.py", line 215, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/loader.py", line 821, in get_component
    raise ImportError(f"Exception importing {self.pkg_path}") from err
ImportError: Exception importing homeassistant.components.mobile_app
2023-10-18 08:48:12.648 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of default_config. Setup failed for dependencies: cloud, mobile_app
2023-10-18 08:48:12.650 ERROR (MainThread) [homeassistant.setup] Setup failed for default_config: (DependencyError(...), 'Could not setup dependencies: cloud, mobile_app')
2023-10-18 08:52:33.236 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/components/http/forwarded.py", line 82, in forwarded_middleware
    from hass_nabucasa import (  # pylint: disable=import-outside-toplevel
  File "/srv/homeassistant/lib/python3.11/site-packages/hass_nabucasa/__init__.py", line 15, in <module>
    from .auth import CloudError, CognitoAuth
  File "/srv/homeassistant/lib/python3.11/site-packages/hass_nabucasa/auth.py", line 11, in <module>
    import boto3
  File "/srv/homeassistant/lib/python3.11/site-packages/boto3/__init__.py", line 17, in <module>
    from boto3.session import Session
  File "/srv/homeassistant/lib/python3.11/site-packages/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/session.py", line 26, in <module>
    import botocore.client
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/client.py", line 15, in <module>
    from botocore import waiter, xform_name
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/waiter.py", line 18, in <module>
    from botocore.docs.docstring import WaiterDocstring
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/__init__.py", line 15, in <module>
    from botocore.docs.service import ServiceDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/service.py", line 14, in <module>
    from botocore.docs.client import ClientDocumenter, ClientExceptionsDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/client.py", line 17, in <module>
    from botocore.docs.example import ResponseExampleDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/example.py", line 13, in <module>
    from botocore.docs.shape import ShapeDocumenter
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/docs/shape.py", line 19, in <module>
    from botocore.utils import is_json_value_header
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/utils.py", line 37, in <module>
    import botocore.httpsession
  File "/srv/homeassistant/lib/python3.11/site-packages/botocore/httpsession.py", line 45, in <module>
    from urllib3.contrib.pyopenssl import (
  File "/srv/homeassistant/lib/python3.11/site-packages/urllib3/contrib/pyopenssl.py", line 97, in <module>
    util.PROTOCOL_TLS: OpenSSL.SSL.SSLv23_METHOD,
    ^^^^^^^^^^^^^^^^^
AttributeError: module 'urllib3.util' has no attribute 'PROTOCOL_TLS'
2023-10-18 08:53:25.915 ERROR (MainThread) [homeassistant.components.homeassistant_alerts] Timeout fetching homeassistant_alerts data

mingqian avatar Oct 18 '23 09:10 mingqian

Just to add here that the above solution did work for me under python 3.11.6 (under pyenv) using the following pipenv Pipfile:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
homeassistant = "*"
wheel = "*"

# aiohttp needs to be fixed at this version for awhile, to prevent an install crash
# https://github.com/home-assistant/core/pull/101932
# aiohttp = "==3.8.5"

# Another issue lel
# https://github.com/home-assistant/core/issues/95192
urllib3 = "==1.26.16"
botocore = {git = "git+https://github.com/boto/botocore"}

[dev-packages]

[requires]
python_version = "3.11"

(I commented out the aiohttp fix because that was from another issue and apparently unneeded)

mikeperalta1 avatar Oct 18 '23 19:10 mikeperalta1

I solved this issue by setting ssl_certificate and ssl_key in the http: section of configuration.yaml

dajomas avatar Nov 11 '23 09:11 dajomas

Same problem here with a fresh Python 3.11.7 venv, homeassistant 2023.12.3, the reported fix still works pip install git+https://github.com/boto/botocore

juicejuice avatar Dec 16 '23 23:12 juicejuice

Ive just done an update to the HA Core which installed ok but after the initial restart some elements of predbat and apex charts wouldn't display. Another restart sorted this out. Is this a problem this fixes? If so how do I install this.

Dave-Parry avatar Jan 10 '24 14:01 Dave-Parry

I have the problem only after the first start. Doing a restart home-assistant comes up (with HTTPS).

bmaehr avatar Feb 16 '24 23:02 bmaehr

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.