Servo Adjusting example code servo_zeroing.py getting AttributeError

when i am running servo_zeroing.py code in terminal window, getting AttributeError: ‘str’ object has no attribute ‘period’
error :
@raspberrypi:~/pi/picar-x/example $ sudo python3 servo_zeroing.py
/usr/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: Your system is neon capable but pygame was not built with support for it. The performance of some of your blits could be adversely affected. Consider enabling compile time detection with environment variables like PYGAME_DETECT_AVX2=1 if you are compiling without cross compilation.
return f(*args, **kwds)
Servo P0 set to zero
Traceback (most recent call last):
File “servo_zeroing.py”, line 13, in
Servo(pin).angle(10)
File “/usr/local/lib/python3.7/dist-packages/robot_hat-1.0.4-py3.7.egg/robot_hat/servo.py”, line 12, in init
self.pwm.period(4095)
I am using V 2.0 picar-x library example code along with I installed all necessary library mentioned tutorial.
please advise : purushotthama

The problem lies in a couple of different places. I am working on a post to make them aware but it seems like it was changes to their github repos specifically the names of functions.

We have resolved the upload well, you follow the steps below:

  1. Uninstall remove picar-x, robot_hat
    cd ~
    sudo pip3 uninstall robot_hat
    sudo rm -rf robot_hat
    sudo pip3 uninstall picar-x
    sudo rm -rf picar-x
  2. Reinstall and download picar-x and robot_hat: 3.
    cd ~
    git clone GitHub - sunfounder/robot-hat: Robot Hat python library
    cd robot-hat
    sudo python3 setup.py install

cd ~
git clone -b v2.0 GitHub - sunfounder/picar-x
cd picar-x
sudo python3 setup.py install

At this point you can try running the example again.

1 Like

Thanks for the update!

1 Like

Hello, I have tried these steps but the error still pops up for me.

/usr/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: Your system is neon capable but pygame was not built with support for it. The performance of some of your blits could be adversely affected. Consider enabling compile time detection with environment variables like PYGAME_DETECT_AVX2=1 if you are compiling without cross compilation.
return f(*args, **kwds)
Set servo to zero
Traceback (most recent call last):
File “servo_zeroing.py”, line 14, in
Servo(pin).angle(10)
File “/usr/local/lib/python3.7/dist-packages/robot_hat-1.0.4-py3.7.egg/robot_hat/servo.py”, line 12, in init
self.pwm.period(4095)
AttributeError: ‘str’ object has no attribute ‘period’

We recommend that you reinstall the Raspberry Pi system, and then follow the tutorial to install the required libraries. During the installation process, please make sure that there is no error message, and if there is, please send us a complete screenshot of the error message, so that we can analyze and solve the problem.