ISSUE:
Recently a new PR was merged to enable spi peripheral interface . To test this on the Q you have to rebuild the core (only works on the 4gb version). After doing that I tried to run the example posted in the PR but ran into issues with spidev not installing correctly, for ref here is the whole app:
SPI3_Test.zip (2.9 KB)
TESTING:
Method 1: Use a requirements.txt file to specify use of spidev
This method tries to install and build spidev=3.8 but fails to build the package for the Q: see: How to install Python Packages - Development Tools / App Lab - Arduino Forum
Using CPython 3.13.9 interpreter at: /usr/local/bin/python
Creating virtual environment at: .cache/.venv
Activating python virtual environment
Traceback (most recent call last):
File "/app/python/main.py", line 4, in <module>
import spidev
ModuleNotFoundError: No module named 'spidev'
Activating python virtual environment
Using Python 3.13.9 environment at: .cache/.venv
Resolved 1 package in 270ms
Building spidev==3.8
× Failed to build `spidev==3.8`
├─▶ The build backend returned an error
╰─▶ Call to `setuptools.build_meta.build_wheel` failed (exit status: 1)
[stdout]
running bdist_wheel
running build
running build_ext
building 'spidev' extension
creating build/temp.linux-aarch64-cpython-313
gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3
-Wall -fPIC -I/app/.cache/uv/builds-v0/.tmpKjKOOd/include
-I/usr/local/include/python3.13 -c spidev_module.c -o
build/temp.linux-aarch64-cpython-313/spidev_module.o
[stderr]
/app/.cache/uv/builds-v0/.tmpKjKOOd/lib/python3.13/site-packages/setuptools/dist.py:765:
SetuptoolsDeprecationWarning: License classifiers are deprecated.
!!
********************************************************************************
Please consider removing the following classifiers in favor of a
SPDX license expression:
License :: OSI Approved :: MIT License
See
https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license
for details.
********************************************************************************
!!
self._finalize_license_expression()
error: command 'gcc' failed: No such file or directory
hint: This usually indicates a problem with the package or the build
environment.
Clearing cache at: .cache/uv
Removed 467 files (4.1MiB)
Traceback (most recent call last):
File "/app/python/main.py", line 4, in <module>
import spidev
ModuleNotFoundError: No module named 'spidev'
exited with code 1
METHOD 2:
Tried to use the method as described here: My problems with App Lab 0.5.0 - Development Tools / App Lab - Arduino Forum
import subprocess
import sys
#import spidev
try:
import spidev
except ModuleNotFoundError:
print("Installing spidev package...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "spidev", "--break-system-packages"])
print("spidev package installed successfully!")
import spidev
But still fails to build
Activating python virtual environment
Installing spidev package...
Collecting spidev
Downloading spidev-3.8.tar.gz (13 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: spidev
Building wheel for spidev (pyproject.toml): started
Building wheel for spidev (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error
× Building wheel for spidev (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
/tmp/pip-build-env-1xu4zdjs/overlay/lib/python3.13/site-packages/setuptools/dist.py:765: SetuptoolsDeprecationWarning: License classifiers are deprecated.
!!
********************************************************************************
Please consider removing the following classifiers in favor of a SPDX license expression:
License :: OSI Approved :: MIT License
See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
********************************************************************************
!!
self._finalize_license_expression()
running bdist_wheel
running build
running build_ext
building 'spidev' extension
creating build/temp.linux-aarch64-cpython-313
gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/app/.cache/.venv/include -I/usr/local/include/python3.13 -c spidev_module.c -o build/temp.linux-aarch64-cpython-313/spidev_module.o
error: command '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
Failed to build spidev
[notice] A new release of pip is available: 25.2 -> 26.0.1
[notice] To update, run: python -m pip install --upgrade pip
error: failed-wheel-build-for-install
× Failed to build installable wheels for some pyproject.toml based projects
╰─> spidev
Traceback (most recent call last):
File "/app/python/main.py", line 7, in <module>
import spidev
ModuleNotFoundError: No module named 'spidev'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/python/main.py", line 10, in <module>
subprocess.check_call([sys.executable, "-m", "pip", "install", "spidev", "--break-system-packages"])
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/subprocess.py", line 419, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/app/.cache/.venv/bin/python', '-m', 'pip', 'install', 'spidev', '--break-system-packages']' returned non-zero exit status 1.
exited with code 1
Method 3: Tried a fake out by creating a python script that only runs the hello world script so I would have a .venv created for the sketch and tried to install manually but:
arduino@arduinoQ4:~/ArduinoApps/copy-of-spi3_test$ source .cache/.venv/bin/activate
(.venv) arduino@arduinoQ4:~/ArduinoApps/copy-of-spi3_test$ which python
(.venv) arduino@arduinoQ4:~/ArduinoApps/copy-of-spi3_test$ which pip
/usr/bin/pip
(.venv) arduino@arduinoQ4:~/ArduinoApps/copy-of-spi3_test$ pip3 install spidev
error: externally-managed-environment
notice when I do a which pip it still points to /usr/bin/pip and gives the standard error about managed environment. Usually to get around that I would use sudo apt-get install python3-spidev. So let try that next.
Method 3.
issued command sudo apt-get install python3-spidev.
In requirements.txt said to use spidev==3.6 you just get the error
Activating python virtual environment
Traceback (most recent call last):
File "/app/python/main.py", line 4, in <module>
import spidev
ModuleNotFoundError: No module named 'spidev'
exited with code 1
So the big question is how to you install package 'spidev for use on the Q?