gateway
gateway copied to clipboard
Install on DietPi
Describe the bug It looks like there is a build error related to missing files required for the project to build successfully. Specifically, the error mentions that the file "Python.h" cannot be found.
/tmp/pip-install-tdkh32ru/theengsgateway_3bc765220bfc4a26abf461f5b8712681/TheengsDecoder/python/TheengsDecoder/_decoder.cpp:2:10: fatal error: Python.h: No such file or directory
System
─────────────────────────────────────────────────────
DietPi v8.15.2 : 19:17 - Tue 03/14/23
─────────────────────────────────────────────────────
- Device model : RPi 4 Model B (aarch64)
- CPU temp : 59 °C / 138 °F : Running warm, but safe
- LAN IP : 192.168.2.37 (eth0)
- MOTD : Check out the DietPi v8.15 release notes:
https://dietpi.com/docs/releases/v8_15/
─────────────────────────────────────────────────────
To Reproduce Steps to reproduce the behavior:
sudo apt-get install python3-pip
pip3 install TheengsGateway
ERROR
root@DietPi:~# pip3 install TheengsGateway
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting TheengsGateway
Downloading TheengsGateway-0.8.0.tar.gz (136 kB)
|████████████████████████████████| 136 kB 4.5 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Collecting bluetooth-clocks<1.0
Downloading https://www.piwheels.org/simple/bluetooth-clocks/bluetooth_clocks-0.1.2-py3-none-any.whl (19 kB)
Collecting paho-mqtt>=1.6.1
Downloading https://www.piwheels.org/simple/paho-mqtt/paho_mqtt-1.6.1-py3-none-any.whl (75 kB)
|████████████████████████████████| 75 kB 604 kB/s
Collecting bleak>=0.15.0
Downloading https://www.piwheels.org/simple/bleak/bleak-0.19.5-py3-none-any.whl (132 kB)
|████████████████████████████████| 132 kB 4.3 MB/s
Collecting dbus-fast<2.0.0,>=1.22.0
Downloading dbus_fast-1.84.2.tar.gz (65 kB)
|████████████████████████████████| 65 kB 1.0 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Collecting async-timeout<5,>=3.0.0
Downloading https://www.piwheels.org/simple/async-timeout/async_timeout-4.0.2-py3-none-any.whl (5.8 kB)
Building wheels for collected packages: TheengsGateway, dbus-fast
Building wheel for TheengsGateway (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 /tmp/tmpckwrtpo1_in_process.py build_wheel /tmp/tmp70lluywg
cwd: /tmp/pip-install-t1t9smxs/theengsgateway_f97c7adefa9a4b76a65d040c02004891
Complete output (79 lines):
/tmp/pip-build-env-p2ubu3m5/overlay/lib/python3.9/site-packages/setuptools/dist.py:547: UserWarning: Normalizing 'v0.8.0' to '0.8.0'
warnings.warn(tmpl.format(**locals()))
--------------------------------------------------------------------------------
-- Trying 'Ninja' generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
Not searching for unused variables given on the command line.
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE):
No CMAKE_C_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "/tmp/pip-install-t1t9smxs/theengsgateway_f97c7adefa9a4b76a65d040c02004891/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
See also "/tmp/pip-install-t1t9smxs/theengsgateway_f97c7adefa9a4b76a65d040c02004891/_cmake_test_compile/build/CMakeFiles/CMakeError.log".
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying 'Ninja' generator - failure
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Trying 'Unix Makefiles' generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
Not searching for unused variables given on the command line.
CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
See also "/tmp/pip-install-t1t9smxs/theengsgateway_f97c7adefa9a4b76a65d040c02004891/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying 'Unix Makefiles' generator - failure
--------------------------------------------------------------------------------
********************************************************************************
scikit-build could not get a working generator for your system. Aborting build.
Building Linux wheels for Python 3.9 requires a compiler (e.g gcc).
It can be installed using debian package manager:
sudo apt-get install build-essential
To build compliant wheels, consider using the manylinux system described in PEP-513.
Get it with "dockcross/manylinux-x64" docker image:
https://github.com/dockcross/dockcross#readme
For more details, please refer to scikit-build documentation:
http://scikit-build.readthedocs.io/en/latest/generators.html#linux
********************************************************************************
----------------------------------------
ERROR: Failed building wheel for TheengsGateway
Building wheel for dbus-fast (PEP 517) ... done
here is the detailed error with pip3 install TheengsGateway --verbose:
Configuring Project
Working directory:
/tmp/pip-install-tdkh32ru/theengsgateway_3bc765220bfc4a26abf461f5b8712681/_skbuild/linux-aarch64-3.9/cmake-build
Command:
/tmp/pip-build-env-wj7erzc4/overlay/lib/python3.9/site-packages/cmake/data/bin/cmake /tmp/pip-install-tdkh32ru/theengsgateway_3bc765220bfc4a26abf461f5b8712681 -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-install-tdkh32ru/theengsgateway_3bc765220bfc4a26abf461f5b8712681/_skbuild/linux-aarch64-3.9/cmake-install -DPYTHON_VERSION_STRING:STRING=3.9.2 -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/tmp/pip-build-env-wj7erzc4/overlay/lib/python3.9/site-packages/skbuild/resources/cmake -DPYTHON_EXECUTABLE:PATH=/usr/bin/python3 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.9 -DPYTHON_LIBRARY:PATH=libpython3.9.a -DPython_EXECUTABLE:PATH=/usr/bin/python3 -DPython_ROOT_DIR:PATH=/usr -DPython_INCLUDE_DIR:PATH=/usr/include/python3.9 -DPython_FIND_REGISTRY:STRING=NEVER -DPython3_EXECUTABLE:PATH=/usr/bin/python3 -DPython3_ROOT_DIR:PATH=/usr -DPython3_INCLUDE_DIR:PATH=/usr/include/python3.9 -DPython3_FIND_REGISTRY:STRING=NEVER -DCMAKE_MAKE_PROGRAM:FILEPATH=/tmp/pip-build-env-wj7erzc4/overlay/lib/python3.9/site-packages/ninja/data/bin/ninja -DCMAKE_BUILD_TYPE:STRING=Release
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python3 (found version "3.9.2")
-- Found PythonLibs: libpython3.9.a
-- Performing Test Weak Link MODULE -> SHARED (gnu_ld_ignore) - Success
_modinit_prefix:PyInit_
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
Python3_EXECUTABLE
Python3_FIND_REGISTRY
Python3_INCLUDE_DIR
Python3_ROOT_DIR
Python_EXECUTABLE
Python_FIND_REGISTRY
Python_INCLUDE_DIR
Python_ROOT_DIR
SKBUILD
-- Build files have been written to: /tmp/pip-install-tdkh32ru/theengsgateway_3bc765220bfc4a26abf461f5b8712681/_skbuild/linux-aarch64-3.9/cmake-build
[1/4] Building CXX object CMakeFiles/_decoder.dir/TheengsDecoder/python/TheengsDecoder/_decoder.cpp.o
FAILED: CMakeFiles/_decoder.dir/TheengsDecoder/python/TheengsDecoder/_decoder.cpp.o
/usr/bin/c++ -D_decoder_EXPORTS -I/usr/include/python3.9 -I/tmp/pip-install-tdkh32ru/theengsgateway_3bc765220bfc4a26abf461f5b8712681/TheengsDecoder/src/arduino_json/src -I/tmp/pip-install-tdkh32ru/theengsgateway_3bc765220bfc4a26abf461f5b8712681/TheengsDecoder/src -O3 -DNDEBUG -fPIC -MD -MT CMakeFiles/_decoder.dir/TheengsDecoder/python/TheengsDecoder/_decoder.cpp.o -MF CMakeFiles/_decoder.dir/TheengsDecoder/python/TheengsDecoder/_decoder.cpp.o.d -o CMakeFiles/_decoder.dir/TheengsDecoder/python/TheengsDecoder/_decoder.cpp.o -c /tmp/pip-install-tdkh32ru/theengsgateway_3bc765220bfc4a26abf461f5b8712681/TheengsDecoder/python/TheengsDecoder/_decoder.cpp
/tmp/pip-install-tdkh32ru/theengsgateway_3bc765220bfc4a26abf461f5b8712681/TheengsDecoder/python/TheengsDecoder/_decoder.cpp:2:10: fatal error: Python.h: No such file or directory
2 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
[2/4] Building CXX object CMakeFiles/_decoder.dir/TheengsDecoder/src/decoder.cpp.o
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "/tmp/pip-build-env-wj7erzc4/overlay/lib/python3.9/site-packages/skbuild/setuptools_wrap.py", line 642, in setup
cmkr.make(make_args, install_target=cmake_install_target, env=env)
File "/tmp/pip-build-env-wj7erzc4/overlay/lib/python3.9/site-packages/skbuild/cmaker.py", line 679, in make
self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
File "/tmp/pip-build-env-wj7erzc4/overlay/lib/python3.9/site-packages/skbuild/cmaker.py", line 710, in make_impl
raise SKBuildError(
An error occurred while building with CMake.
Command:
/tmp/pip-build-env-wj7erzc4/overlay/lib/python3.9/site-packages/cmake/data/bin/cmake --build . --target install --config Release --
Install target:
install
Source directory:
/tmp/pip-install-tdkh32ru/theengsgateway_3bc765220bfc4a26abf461f5b8712681
Working directory:
/tmp/pip-install-tdkh32ru/theengsgateway_3bc765220bfc4a26abf461f5b8712681/_skbuild/linux-aarch64-3.9/cmake-build
Please check the install target is valid and see CMake's output for more information.
Building wheel for TheengsGateway (PEP 517) ... error
ERROR: Failed building wheel for TheengsGateway
Failed to build TheengsGateway
ERROR: Could not build wheels for TheengsGateway which use PEP 517 and cannot be installed directly
Exception information:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 223, in _main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 180, in wrapper
return func(self, options, args)
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 388, in run
raise InstallationError(
pip._internal.exceptions.InstallationError: Could not build wheels for TheengsGateway which use PEP 517 and cannot be installed directly
Removed build tracker: '/tmp/pip-req-tracker-_6ahxcx6'
Here is how I succesfully installed it on my RP4 running DietPi 8.15:
-
Turn on Bluetooth:
dietpi-config
-
Check status of BT:
sudo systemctl status bluetooth
should look like this:
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2023-03-14 19:21:02 GMT; 37min ago
Docs: man:bluetoothd(8)
Main PID: 1636 (bluetoothd)
Status: "Running"
Tasks: 1 (limit: 2197)
CPU: 499ms
CGroup: /system.slice/bluetooth.service
└─1636 /usr/libexec/bluetooth/bluetoothd
Mar 14 19:21:02 DietPi systemd[1]: Starting Bluetooth service...
Mar 14 19:21:02 DietPi bluetoothd[1636]: Bluetooth daemon 5.55
Mar 14 19:21:02 DietPi systemd[1]: Started Bluetooth service.
Mar 14 19:21:02 DietPi bluetoothd[1636]: Starting SDP server
Mar 14 19:21:02 DietPi bluetoothd[1636]: Bluetooth management interface 1.21 initialized
-
Check Python version:
python3 --version
should look like this:Python 3.9.2
-
Check if PIP is installed:
python3 -m pip --version
If not install with:sudo apt-get install python3-pip
-
Install build essentials:
sudo apt-get update
sudo apt-get install build-essential
-
Install
apt-get install python3-dev
to solve the problem with the missing "Python.h"apt-get install python3-dev
-
Install TheengsGateway with pip:
pip3 install TheengsGateway
-
Make a test run like this:
python3 -m TheengsGateway -H "YOURBROKERIP" -u "USERNAME" -p "PASSOWRD"
or with debug details:python3 -m TheengsGateway -H "YOURBROKERIP" -u "USERNAME" -p "PASSOWRD" -ll "DEBUG"
(9. Run it as a service) https://github.com/theengs/gateway/discussions/5#discussioncomment-2282815
here is the service I use to run as a user without root privilege. But make sure to run it first with the needed parameter under the user you would like to run it later as a service
nano /etc/systemd/system/TheengsGateway.service
[Unit]
Description=Theengs Gateway
After=network.target
[Service]
Restart=always
Type=simple
User=loxberry
Group=loxberry
ExecStart=/usr/bin/python3 -m TheengsGateway
[Install]
WantedBy=multi-user.target
Enable it:
sudo systemctl daemon-reload
sudo systemctl enable --now TheengsGateway.service
Check the status:
sudo journalctl -u TheengsGateway.service -f
Thanks for the tutorial! Out of curiosity seeing your nickname, are you using Theengs with Matlab?
Thanks for the tutorial! Out of curiosity seeing your nickname, are you using Theengs with Matlab?
I used matlab a long time ago. I think the ability of python makes matlab obsolete for me.
The apt-get install python3-dev just did the trick for me trying to install on an Orange Pi 3 LTS. Thank you!