HomeAssistant Core - Python3.11 Upgrade - Can't get HA Installed. Building wheel for lru-dict (setup.py) ... error

Hi Everyone,

I need to update my Python from 3.10 to 3.11 due to the new HA version 2023.6.1

I follow the same steps I did during previous python updates that is:

  • Stop HA
  • mv /opt/homeassistant/ /opt/homeassistantold/
  • sudo dnf -y install python3.11
  • sudo su -s /bin/bash homeassistant
  • cd /opt/homeassistant/
  • python3.11 -m venv /opt/homeassistant
  • source bin/activate
  • pip3 install --upgrade homeassistant

I am getting this error:

Requirement already satisfied: pycparser in ./lib64/python3.11/site-packages (from cffi>=1.12->cryptography==40.0.2->homeassistant) (2.21)
Collecting h11<0.15,>=0.13 (from httpcore<0.18.0,>=0.15.0->httpx==0.24.1->homeassistant)
  Using cached h11-0.14.0-py3-none-any.whl (58 kB)
Collecting anyio<5.0,>=3.0 (from httpcore<0.18.0,>=0.15.0->httpx==0.24.1->homeassistant)
  Using cached anyio-3.7.0-py3-none-any.whl (80 kB)
**Building wheels for collected packages: lru-dict**
**  Building wheel for lru-dict (setup.py) ... error**
  **error: subprocess-exited-with-error**

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'lru' extension
      creating build
      creating build/temp.linux-x86_64-3.11
      gcc -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/opt/homeassistant/include -I/usr/include/python3.11 -c lru.c -o build/temp.linux-x86_64-3.11/lru.o
      lru.c:1:10: fatal error: Python.h: No such file or directory
          1 | #include <Python.h>
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for lru-dict
  Running setup.py clean for lru-dict
Failed to build lru-dict
ERROR: Could not build wheels for lru-dict, which is required to install pyproject.toml-based projects

I tried to:
python3 -m pip install wheel
python3 -m pip install lru-dict

But it didn’t help !

Do you have some suggestion?

I appreciate very much your help !!!

This is the full installation log:

(homeassistant) [homeassistant@hanew homeassistant]$ pip3 install homeassistant
Collecting homeassistant
  Using cached homeassistant-2023.6.1-py3-none-any.whl (25.3 MB)
Requirement already satisfied: aiohttp==3.8.4 in ./lib64/python3.11/site-packages (from homeassistant) (3.8.4)
Collecting astral==2.2 (from homeassistant)
  Using cached astral-2.2-py2.py3-none-any.whl (30 kB)
Requirement already satisfied: async-timeout==4.0.2 in ./lib64/python3.11/site-packages (from homeassistant) (4.0.2)
Collecting attrs==22.2.0 (from homeassistant)
  Using cached attrs-22.2.0-py3-none-any.whl (60 kB)
Requirement already satisfied: atomicwrites-homeassistant==1.4.1 in ./lib64/python3.11/site-packages (from homeassistant) (1.4.1)
Collecting awesomeversion==22.9.0 (from homeassistant)
  Using cached awesomeversion-22.9.0-py3-none-any.whl (12 kB)
Collecting bcrypt==4.0.1 (from homeassistant)
  Using cached bcrypt-4.0.1-cp36-abi3-manylinux_2_28_x86_64.whl (593 kB)
Requirement already satisfied: certifi>=2021.5.30 in ./lib64/python3.11/site-packages (from homeassistant) (2023.5.7)
Collecting ciso8601==2.3.0 (from homeassistant)
  Using cached ciso8601-2.3.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (39 kB)
Collecting httpx==0.24.1 (from homeassistant)
  Using cached httpx-0.24.1-py3-none-any.whl (75 kB)
Collecting home-assistant-bluetooth==1.10.0 (from homeassistant)
  Using cached home_assistant_bluetooth-1.10.0-cp311-cp311-manylinux_2_34_x86_64.whl
Collecting ifaddr==0.2.0 (from homeassistant)
  Using cached ifaddr-0.2.0-py3-none-any.whl (12 kB)
Collecting jinja2==3.1.2 (from homeassistant)
  Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)
Collecting lru-dict==1.1.8 (from homeassistant)
  Using cached lru-dict-1.1.8.tar.gz (10 kB)
  Preparing metadata (setup.py) ... done
Collecting PyJWT==2.7.0 (from homeassistant)
  Using cached PyJWT-2.7.0-py3-none-any.whl (22 kB)
Collecting cryptography==40.0.2 (from homeassistant)
  Using cached cryptography-40.0.2-cp36-abi3-manylinux_2_28_x86_64.whl (3.7 MB)
Collecting pyOpenSSL==23.1.0 (from homeassistant)
  Using cached pyOpenSSL-23.1.0-py3-none-any.whl (57 kB)
Collecting orjson==3.8.12 (from homeassistant)
  Using cached orjson-3.8.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (137 kB)
Requirement already satisfied: pip<23.2,>=21.0 in ./lib64/python3.11/site-packages (from homeassistant) (23.1.2)
Collecting python-slugify==4.0.1 (from homeassistant)
  Using cached python_slugify-4.0.1-py2.py3-none-any.whl
Collecting pyyaml==6.0 (from homeassistant)
  Using cached PyYAML-6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (757 kB)
Requirement already satisfied: requests==2.31.0 in ./lib64/python3.11/site-packages (from homeassistant) (2.31.0)
Collecting typing-extensions<5.0,>=4.5.0 (from homeassistant)
  Using cached typing_extensions-4.6.3-py3-none-any.whl (31 kB)
Collecting ulid-transform==0.7.2 (from homeassistant)
  Using cached ulid_transform-0.7.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (160 kB)
Collecting voluptuous==0.13.1 (from homeassistant)
  Using cached voluptuous-0.13.1-py3-none-any.whl (29 kB)
Collecting voluptuous-serialize==2.6.0 (from homeassistant)
  Using cached voluptuous_serialize-2.6.0-py3-none-any.whl (6.8 kB)
Requirement already satisfied: yarl==1.9.2 in ./lib64/python3.11/site-packages (from homeassistant) (1.9.2)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in ./lib64/python3.11/site-packages (from aiohttp==3.8.4->homeassistant) (3.1.0)
Requirement already satisfied: multidict<7.0,>=4.5 in ./lib64/python3.11/site-packages (from aiohttp==3.8.4->homeassistant) (6.0.4)
Requirement already satisfied: frozenlist>=1.1.1 in ./lib64/python3.11/site-packages (from aiohttp==3.8.4->homeassistant) (1.3.3)
Requirement already satisfied: aiosignal>=1.1.2 in ./lib64/python3.11/site-packages (from aiohttp==3.8.4->homeassistant) (1.3.1)
Requirement already satisfied: pytz in ./lib64/python3.11/site-packages (from astral==2.2->homeassistant) (2023.3)
Requirement already satisfied: cffi>=1.12 in ./lib64/python3.11/site-packages (from cryptography==40.0.2->homeassistant) (1.15.1)
Collecting httpcore<0.18.0,>=0.15.0 (from httpx==0.24.1->homeassistant)
  Using cached httpcore-0.17.2-py3-none-any.whl (72 kB)
Requirement already satisfied: idna in ./lib64/python3.11/site-packages (from httpx==0.24.1->homeassistant) (3.4)
Collecting sniffio (from httpx==0.24.1->homeassistant)
  Using cached sniffio-1.3.0-py3-none-any.whl (10 kB)
Collecting MarkupSafe>=2.0 (from jinja2==3.1.2->homeassistant)
  Using cached MarkupSafe-2.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (28 kB)
Collecting text-unidecode>=1.3 (from python-slugify==4.0.1->homeassistant)
  Using cached text_unidecode-1.3-py2.py3-none-any.whl (78 kB)
Requirement already satisfied: urllib3<3,>=1.21.1 in ./lib64/python3.11/site-packages (from requests==2.31.0->homeassistant) (1.26.16)
Requirement already satisfied: pycparser in ./lib64/python3.11/site-packages (from cffi>=1.12->cryptography==40.0.2->homeassistant) (2.21)
Collecting h11<0.15,>=0.13 (from httpcore<0.18.0,>=0.15.0->httpx==0.24.1->homeassistant)
  Using cached h11-0.14.0-py3-none-any.whl (58 kB)
Collecting anyio<5.0,>=3.0 (from httpcore<0.18.0,>=0.15.0->httpx==0.24.1->homeassistant)
  Using cached anyio-3.7.0-py3-none-any.whl (80 kB)
Building wheels for collected packages: lru-dict
  Building wheel for lru-dict (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'lru' extension
      creating build
      creating build/temp.linux-x86_64-3.11
      gcc -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/opt/homeassistant/include -I/usr/include/python3.11 -c lru.c -o build/temp.linux-x86_64-3.11/lru.o
      lru.c:1:10: fatal error: Python.h: No such file or directory
          1 | #include <Python.h>
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for lru-dict
  Running setup.py clean for lru-dict
Failed to build lru-dict
ERROR: Could not build wheels for lru-dict, which is required to install pyproject.toml-based projects
(homeassistant) [homeassistant@hanew homeassistant]$ exit^C
(homeassistant) [homeassistant@hanew homeassistant]$ python3 -m pip install lru-dict
Requirement already satisfied: lru-dict in ./lib64/python3.11/site-packages (1.2.0)

You need to make sure all the OS dependencies are installed. https://www.home-assistant.io/installation/linux#install-dependencies

Looks like you’re missing the equivalent of python3-dev.

Hi @freshcoast thank you for answering !!!

I had installed the python3-devel but I didn’t realize I need python3.11-devel

so after I did

dnf install python3.11-dev (in my case, Fedora, it is dnf but could be apt for some other distr)

that error was solved.

THANK YOU !!!