Running servoTest.py in Thonny I get the following result, does any one have an idea of the problem
I am trying to run a pan and tilt camera setup using i2c7 output.
from adafruit_servokit import ServoKit
sKit=ServoKit(channels=16)
sKit.servo[0].angle=45
“Error in Thonny”
Python 3.9.2 (/usr/bin/python3)
%Run servoTest.py
ImportError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “/home/ali/servoTest.py”, line 1, in
from adafruit_servokit import ServoKit
File “/usr/local/lib/python3.9/dist-packages/adafruit_servokit.py”, line 35, in
import board
File “/usr/local/lib/python3.9/dist-packages/board.py”, line 251, in
from adafruit_blinka.board.radxa.rockpi4 import *
File “/usr/local/lib/python3.9/dist-packages/adafruit_blinka/board/radxa/rockpi4.py”, line 7, in
from adafruit_blinka.microcontroller.rockchip.rk3399 import pin
File “/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/rockchip/rk3399/pin.py”, line 7, in
from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
File “/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod_pin.py”, line 8, in
raise ImportError(
ImportError: libgpiod Python bindings not found, please install and try again! See https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/master/libgpiod.sh
it seems that libgpiod is not installed.
try opening python3 and importing it manually:
python3
import libgpiod
if this failes then it needs to be installed
if this succeeds then you it is installed, probably in your users sub directory and when you use sudo, PYTHON_PATH environment variable is not including libs installed under your user.
Thank you for your quick response, I am new to linux, I checked and I could import libgpiod.
I find libgpiod.py and libgpiod.sh is in my /home/ali directory, but not sure what to do now, i;ve never set up paths before.
the easiest way would be with exporting with new value:
export PYTHONPATH=$PYTHONPATH:$HOME
the issue is that it is not consistent and every time you exit your dev environment, you’ll have to run the command every time.
You can make it permanent by saving the code below at the end of /etc/bash.bashrc file
from adafruit_servokit import ServoKit
kit = ServoKit(channels=16)
kit.servo[0].angle = 90
Python 3.9.2 (/usr/bin/python3)
%Run servoTest.py
ImportError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “/home/ali/servoTest.py”, line 1, in
from adafruit_servokit import ServoKit
File “/usr/local/lib/python3.9/dist-packages/adafruit_servokit.py”, line 35, in
import board
File “/usr/local/lib/python3.9/dist-packages/board.py”, line 251, in
from adafruit_blinka.board.radxa.rockpi4 import *
File “/usr/local/lib/python3.9/dist-packages/adafruit_blinka/board/radxa/rockpi4.py”, line 7, in
from adafruit_blinka.microcontroller.rockchip.rk3399 import pin
File “/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/rockchip/rk3399/pin.py”, line 7, in
from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
File “/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod_pin.py”, line 8, in
raise ImportError(
ImportError: libgpiod Python bindings not found, please install and try again! See https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/master/libgpiod.sh
Line I have added as you have shown to /etc/bash.bashrc file
echo PYTHONPATH=$PYTHONPATH:/home/ali >> /etc/bash.bashrc
thank you again for helping
Alistair
I have just noticed at the top of the terminal ** bash: /etc/bash.bashrc: Permison denied **
This may be my problem, have I added the echo line wrongly ?
Alistair
Ran code and get a permission error on /dev/gpiochip0
Running thonny as sudo gets a “no module names adafruit_servoKit” when running the code which I didn’t get in KDE, but a quick dirty chmod for others on the /dev/gpiochip(s) and the code gets to “No Hardware on I2C” (which there isn’t).
Please note that chmodding for others on /dev/gpiochip# is definitely NOT the recommended method for giving access to them and shouldn’t really be done for anything other than testing. Make sure to undo rights changes for other if you do this and go the extra mile to grant access to non root.
getting same error as you plus
Traceback (most recent call last):
File “/home/ali/servoTest.py”, line 1, in
from adafruit_servokit import ServoKit
File “/usr/local/lib/python3.9/dist-packages/adafruit_servokit.py”, line 35, in
import board
File “/usr/local/lib/python3.9/dist-packages/board.py”, line 251, in
from adafruit_blinka.board.radxa.rockpi4 import *
File “/usr/local/lib/python3.9/dist-packages/adafruit_blinka/board/radxa/rockpi4.py”, line 7, in
from adafruit_blinka.microcontroller.rockchip.rk3399 import pin
File “/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/rockchip/rk3399/pin.py”, line 7, in
from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
File “/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod_pin.py”, line 8, in
I’m getting no hardware on I2C error because I don’t have any hardware on I2C. I’m assuming that if I did have hardware attached then it would be working.
If you have hardware attached and getting a no hardware on I2C error then I’m afraid I can’t really help any further.
Yes I have the hardware connected but still not working, given up now trying to get it to work, will maybe think of some other way using pwm pins.
Thank you for your help, much appreciated.