GPIO на python3

я пробую согласно инструкции установить библиотеку python для работы с gpio портами. Смотрел и качал от сюда GitHub - wirenboard/wb-io-python: Generic IO Python Library. На python2.7 нет проблем с установкой и пользованием. Python3 не видит установленную библиотеку, а при попытке установить библиотеку “python3 install …” выдает море ошибок. Есть ли решение или способ управлять портами gpio без библиотеки?

добрый день! Рекомендуемый способ работы с дискретными входами и выходами в Wiren Board - это MQTT.

Ещё можно попробовать gpiod · PyPI , хотя вам придётся парсить номера и смещения gpiochip самостоятельно.

Если расскажете подробно, что значит

, то попробуем помочь и с wb-io-python

вывод из терминала:
root@wirenboard-ACV3XJFC:~# python3 /home/sender3.py
Traceback (most recent call last):
File “/home/sender3.py”, line 3, in
import WB_IO.GPIO as GPIO
ImportError: No module named 'WB_IO’
root@wirenboard-ACV3XJFC:~#
root@wirenboard-ACV3XJFC:~# python /home/sender3.py
close failed in file object destructor:
connected
GPIO INIT
waiting…
rotate key
locking KU…
thread1 joining…
thread1 joined
KU >>LOCKED
rotate key
KU >>unlocked
Причём в инсталяторе написано

classifiers = [‘Development Status :: 3 - Alpha’,
‘Operating System :: POSIX :: Linux’,
‘License :: OSI Approved :: MIT License’,
‘Intended Audience :: Developers’,
‘Programming Language :: Python :: 2.6’,
‘Programming Language :: Python :: 2.7’,
‘Programming Language :: Python :: 3’,
‘Topic :: Software Development’,
‘Topic :: Home Automation’,
‘Topic :: System :: Hardware’]
Как в библиотеке PRI.GPIO, так что она должна хотябы видна питону 3?
Возможно ли перемещение папки библиотеки в иную директорию или директорию проекта для хотя бы нахождения её программой?

Вывод терминала при установке библиотеки

root@wirenboard-ACV3XJFC:~# python3 /home/python/wb-io-python/setup.py install
  File "/home/python/wb-io-python/setup.py", line 7
    print "py_compile module missing; installing to %spy_compile.py" %\
                                                                   ^
SyntaxError: Missing parentheses in call to 'print'
root@wirenboard-ACV3XJFC:~#

после заключения аргументов print в скобочки

root@wirenboard-ACV3XJFC:~# python3 /home/python/wb-io-python/setup.py install File “/home/python/wb-io-python/setup.py”, line 18
except Exception, e:
^
SyntaxError: invalid syntax
root@wirenboard-ACV3XJFC:~#

выходит ошибка возможна при импорте py_compile , как как консольне вывела print после вывода

try:
import py_compile
print (“py_compile installed successfully”)
except Exception, e:

Ещё вывод из терминала:

root@wirenboard-ACV3XJFC:/home/python/wb-io-python# python3 setup.py install File “setup.py”, line 18
except Exception, e:
^
SyntaxError: invalid syntax
root@wirenboard-ACV3XJFC:/home/python/wb-io-python# python2 setup.py install
running install
running bdist_egg
running egg_info
writing WB_IO.egg-info/PKG-INFO
writing top-level names to WB_IO.egg-info/top_level.txt
writing dependency_links to WB_IO.egg-info/dependency_links.txt
file gpio_sysfs.py (for module gpio_sysfs) not found
reading manifest file ‘WB_IO.egg-info/SOURCES.txt’
reading manifest template ‘MANIFEST.in’
writing manifest file ‘WB_IO.egg-info/SOURCES.txt’
installing library code to build/bdist.linux-armv7l/egg
running install_lib
running build_py
file gpio_sysfs.py (for module gpio_sysfs) not found
file gpio_sysfs.py (for module gpio_sysfs) not found
running build_ext
creating build/bdist.linux-armv7l/egg
creating build/bdist.linux-armv7l/egg/WB_IO
copying build/lib.linux-armv7l-2.7/WB_IO/gpio_sysfs.py → build/bdist.linux-armv7l/egg/WB_IO
copying build/lib.linux-armv7l-2.7/WB_IO/init.py → build/bdist.linux-armv7l/egg/WB_IO
copying build/lib.linux-armv7l-2.7/WB_IO/SPI.so → build/bdist.linux-armv7l/egg/WB_IO
copying build/lib.linux-armv7l-2.7/WB_IO/GPIO.so → build/bdist.linux-armv7l/egg/WB_IO
byte-compiling build/bdist.linux-armv7l/egg/WB_IO/gpio_sysfs.py to gpio_sysfs.pyc
byte-compiling build/bdist.linux-armv7l/egg/WB_IO/init.py to init.pyc
creating stub loader for WB_IO/GPIO.so
creating stub loader for WB_IO/SPI.so
byte-compiling build/bdist.linux-armv7l/egg/WB_IO/GPIO.py to GPIO.pyc
byte-compiling build/bdist.linux-armv7l/egg/WB_IO/SPI.py to SPI.pyc
creating build/bdist.linux-armv7l/egg/EGG-INFO
copying WB_IO.egg-info/PKG-INFO → build/bdist.linux-armv7l/egg/EGG-INFO
copying WB_IO.egg-info/SOURCES.txt → build/bdist.linux-armv7l/egg/EGG-INFO
copying WB_IO.egg-info/dependency_links.txt → build/bdist.linux-armv7l/egg/EGG-INFO
copying WB_IO.egg-info/top_level.txt → build/bdist.linux-armv7l/egg/EGG-INFO
writing build/bdist.linux-armv7l/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents…
creating ‘dist/WB_IO-1.0.0-py2.7-linux-armv7l.egg’ and adding ‘build/bdist.linux-armv7l/egg’ to it
removing ‘build/bdist.linux-armv7l/egg’ (and everything under it)
Processing WB_IO-1.0.0-py2.7-linux-armv7l.egg
Removing /usr/local/lib/python2.7/dist-packages/WB_IO-1.0.0-py2.7-linux-armv7l.egg
Copying WB_IO-1.0.0-py2.7-linux-armv7l.egg to /usr/local/lib/python2.7/dist-packages
WB-IO 1.0.0 is already the active version in easy-install.pth

Installed /usr/local/lib/python2.7/dist-packages/WB_IO-1.0.0-py2.7-linux-armv7l.egg
Processing dependencies for WB-IO==1.0.0
Finished processing dependencies for WB-IO==1.0.0
root@wirenboard-ACV3XJFC:/home/python/wb-io-python#

А это после исправления строки exeption

root@wirenboard-ACV3XJFC:/home/python/wb-io-python# python3 setup.py install
running install
running bdist_egg
running egg_info
writing WB_IO.egg-info/PKG-INFO
writing dependency_links to WB_IO.egg-info/dependency_links.txt
writing top-level names to WB_IO.egg-info/top_level.txt
file gpio_sysfs.py (for module gpio_sysfs) not found
reading manifest file ‘WB_IO.egg-info/SOURCES.txt’
reading manifest template ‘MANIFEST.in’
writing manifest file ‘WB_IO.egg-info/SOURCES.txt’
installing library code to build/bdist.linux-armv7l/egg
running install_lib
running build_py
file gpio_sysfs.py (for module gpio_sysfs) not found
creating build/lib.linux-armv7l-3.5
creating build/lib.linux-armv7l-3.5/WB_IO
copying WB_IO/gpio_sysfs.py → build/lib.linux-armv7l-3.5/WB_IO
copying WB_IO/init.py → build/lib.linux-armv7l-3.5/WB_IO
file gpio_sysfs.py (for module gpio_sysfs) not found
running build_ext
building ‘WB_IO.GPIO’ extension
creating build/temp.linux-armv7l-3.5
creating build/temp.linux-armv7l-3.5/source
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-0jwNE7/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/py_gpio.c -o build/temp.linux-armv7l-3.5/source/py_gpio.o
source/py_gpio.c:36:18: warning: ‘bb_revision’ defined but not used [-Wunused-variable]
static PyObject *bb_revision;
^~~~~~~~~~~
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-0jwNE7/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/event_gpio.c -o build/temp.linux-armv7l-3.5/source/event_gpio.o
source/event_gpio.c: In function ‘gpio_export’:
source/event_gpio.c:101:5: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(fd, str_gpio, len);
^~~~~~~~~~~~~~~~~~~~~~~~
source/event_gpio.c: In function ‘gpio_unexport’:
source/event_gpio.c:209:5: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(fd, str_gpio, len);
^~~~~~~~~~~~~~~~~~~~~~~~
source/event_gpio.c: In function ‘gpio_set_direction’:
source/event_gpio.c:249:9: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(fd, direction, strlen(direction));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
source/event_gpio.c: In function ‘gpio_get_direction’:
source/event_gpio.c:265:5: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
read(fd, &direction, sizeof(direction) - 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
source/event_gpio.c: In function ‘gpio_set_value’:
source/event_gpio.c:293:5: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(fd, vstr, strlen(vstr));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
source/event_gpio.c: In function ‘gpio_get_value’:
source/event_gpio.c:310:5: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
read(fd, &ch, sizeof(ch));
^~~~~~~~~~~~~~~~~~~~~~~~~
source/event_gpio.c: In function ‘gpio_set_edge’:
source/event_gpio.c:331:9: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(fd, stredge[edge], strlen(stredge[edge]) + 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-0jwNE7/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/constants.c -o build/temp.linux-armv7l-3.5/source/constants.o
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-0jwNE7/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/common.c -o build/temp.linux-armv7l-3.5/source/common.o
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -g -fdebug-prefix-map=/build/python3.5-0jwNE7/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-armv7l-3.5/source/py_gpio.o build/temp.linux-armv7l-3.5/source/event_gpio.o build/temp.linux-armv7l-3.5/source/constants.o build/temp.linux-armv7l-3.5/source/common.o -o build/lib.linux-armv7l-3.5/WB_IO/GPIO.cpython-35m-arm-linux-gnueabihf.so
building ‘WB_IO.SPI’ extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-0jwNE7/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/spimodule.c -o build/temp.linux-armv7l-3.5/source/spimodule.o
source/spimodule.c: In function ‘SPI_dealloc’:
source/spimodule.c:97:6: error: ‘SPI {aka struct }’ has no member named ‘ob_type’; did you mean ‘ob_base’?
self->ob_type->tp_free((PyObject *)self);
^~
source/spimodule.c: In function ‘SPI_writebytes’:
source/spimodule.c:134:8: warning: implicit declaration of function ‘PyInt_Check’ [-Wimplicit-function-declaration]
if (!PyInt_Check(val)) {
^~~~~~~~~~~
source/spimodule.c:138:19: warning: implicit declaration of function ‘PyInt_AS_LONG’ [-Wimplicit-function-declaration]
buf[ii] = (__u8)PyInt_AS_LONG(val);
^~~~~~~~~~~~~
source/spimodule.c: In function ‘SPI_set_mode’:
source/spimodule.c:546:9: warning: implicit declaration of function ‘PyInt_AsLong’ [-Wimplicit-function-declaration]
mode = PyInt_AsLong(val);
^~~~~~~~~~~~
In file included from /usr/include/python3.5m/pytime.h:6:0,
from /usr/include/python3.5m/Python.h:65,
from source/spimodule.c:26:
source/spimodule.c: At top level:
/usr/include/python3.5m/object.h:86:5: warning: missing braces around initializer [-Wmissing-braces]
{ _PyObject_EXTRA_INIT
^
source/spimodule.c:869:2: note: in expansion of macro ‘PyObject_HEAD_INIT’
PyObject_HEAD_INIT(NULL)
^~~~~~~~~~~~~~~~~~
/usr/include/python3.5m/object.h:86:5: note: (near initialization for ‘SPI_type.ob_base’)
{ _PyObject_EXTRA_INIT
^
source/spimodule.c:869:2: note: in expansion of macro ‘PyObject_HEAD_INIT’
PyObject_HEAD_INIT(NULL)
^~~~~~~~~~~~~~~~~~
source/spimodule.c:871:2: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
“SPI”, /* tp_name */
^~~~~
source/spimodule.c:871:2: note: (near initialization for ‘SPI_type.tp_basicsize’)
source/spimodule.c:874:2: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
(destructor)SPI_dealloc, /* tp_dealloc /
^
source/spimodule.c:874:2: note: (near initialization for ‘SPI_type.tp_print’)
In file included from /usr/include/python3.5m/pytime.h:6:0,
from /usr/include/python3.5m/Python.h:65,
from source/spimodule.c:26:
/usr/include/python3.5m/object.h:651:29: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
#define Py_TPFLAGS_DEFAULT (
^
source/spimodule.c:889:2: note: in expansion of macro ‘Py_TPFLAGS_DEFAULT’
Py_TPFLAGS_DEFAULT, /
tp_flags */
^~~~~~~~~~~~~~~~~~
/usr/include/python3.5m/object.h:651:29: note: (near initialization for ‘SPI_type.tp_doc’)
#define Py_TPFLAGS_DEFAULT (
^
source/spimodule.c:889:2: note: in expansion of macro ‘Py_TPFLAGS_DEFAULT’
Py_TPFLAGS_DEFAULT, /* tp_flags */
^~~~~~~~~~~~~~~~~~
source/spimodule.c:890:2: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
SPI_type_doc, /* tp_doc */
^~~~~~~~~~~~
source/spimodule.c:890:2: note: (near initialization for ‘SPI_type.tp_traverse’)
source/spimodule.c:897:2: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
SPI_methods, /* tp_methods */
^~~~~~~~~~~
source/spimodule.c:897:2: note: (near initialization for ‘SPI_type.tp_members’)
source/spimodule.c:899:2: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
SPI_getset, /* tp_getset */
^~~~~~~~~~
source/spimodule.c:899:2: note: (near initialization for ‘SPI_type.tp_base’)
source/spimodule.c:905:2: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
(initproc)SPI_init, /* tp_init /
^
source/spimodule.c:905:2: note: (near initialization for ‘SPI_type.tp_alloc’)
source/spimodule.c:907:2: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
SPI_new, /
tp_new */
^~~~~~~
source/spimodule.c:907:2: note: (near initialization for ‘SPI_type.tp_free’)
source/spimodule.c:868:32: warning: missing braces around initializer [-Wmissing-braces]
static PyTypeObject SPI_type = {
^
source/spimodule.c:868:32: note: (near initialization for ‘SPI_type’)
source/spimodule.c: In function ‘initSPI’:
source/spimodule.c:923:3: warning: ‘return’ with no value, in function returning non-void
return;
^~~~~~
source/spimodule.c:918:1: note: declared here
initSPI(void)
^~~~~~~
source/spimodule.c:925:6: warning: implicit declaration of function ‘Py_InitModule3’ [-Wimplicit-function-declaration]
m = Py_InitModule3(“SPI”, SPI_module_methods, SPI_module_doc);
^~~~~~~~~~~~~~
source/spimodule.c:925:4: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
m = Py_InitModule3(“SPI”, SPI_module_methods, SPI_module_doc);
^
error: command ‘arm-linux-gnueabihf-gcc’ failed with exit status 1
root@wirenboard-ACV3XJFC:/home/python/wb-io-python#