Installing spidev

I am trying to install the python module spidev on a clean install. I have tried two ways:

root@PiGi:~# apt install python3-spidev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 python3-spidev : Depends: python3 (< 3.10) but 3.11.2-1 is to be installed
E: Unable to correct problems, you have held broken packages.

root@PiGi:~# pip install spidev
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple/
Collecting spidev
  Downloading spidev-3.6.tar.gz (11 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: spidev
  Building wheel for spidev (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for spidev (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      /tmp/pip-build-env-9b8q41f0/overlay/local/lib/python3.11/dist-packages/setuptools/dist.py:744: SetuptoolsDeprecationWarning: Invalid dash-separated options
      !!

              ********************************************************************************
              Usage of dash-separated 'description-file' will not be supported in future
              versions. Please use the underscore name 'description_file' instead.

              By 2023-Sep-26, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.

              See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
              ********************************************************************************

      !!
        opt = self.warn_dash_deprecation(opt, section)
      running bdist_wheel
      running build
      running build_ext
      building 'spidev' extension
      creating build
      creating build/temp.linux-armv6l-cpython-311
      arm-linux-gnueabihf-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/python3.11 -c spidev_module.c -o build/temp.linux-armv6l-cpython-311/spidev_module.o
      error: command 'arm-linux-gnueabihf-gcc' failed: No such file or directory
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for spidev

Any suggestions?

Can you please fill out the troubleshooting template?
When Iook I here python3-spidev should need python3 (< 3.12) and not < 3.10.
Did you tried apt update before installation?

I did run apt update first:

root@PiGi:~# apt update
Get:1 http://raspbian.raspberrypi.org/raspbian bookworm InRelease [15.0 kB]
Hit:2 https://archive.raspberrypi.org/debian bullseye InRelease
Fetched 15.0 kB in 3s (4,929 B/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
root@PiGi:~# apt install python3-spidev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 python3-spidev : Depends: python3 (< 3.10) but 3.11.2-1 is to be installed
E: Unable to correct problems, you have held broken packages.

Required Information

  • DietPi version | G_DIETPI_VERSION_CORE=8
    G_DIETPI_VERSION_SUB=21
    G_DIETPI_VERSION_RC=1

  • Distro version | bookworm 1

  • Kernel version | Linux PiGi 6.1.21+ #1642 Mon Apr 3 17:19:14 BST 2023 armv6l GNU/Linux

  • Architecture | armhf

  • SBC model | RPi Zero W (armv6l)

ok I see. python3-spidev is pulled from https://archive.raspberrypi.org/ Bullseye repository, while python3 is pulled from http://raspbian.raspberrypi.org/ Bookworm repository. This is causing a conflict between versions now. Unfortunately there is still no Bookworm repository available from https://archive.raspberrypi.org/ :face_exhaling:

The other method tried is the pyton pip install. There you are missing some compiler :wink:

you could try following to install required files

apt install gcc-arm-linux-gnueabihf

Perfect, thanks!