Pan-Tilt Hat Python Library Lacks idle_timeout in "_init.py_"


#1

(TL;DR at bottom)

I am totally a neeewb to Linux and, for all intents and purposes, a neewb to programming. I bought a picam and the awesome Pan-Tilt Hat because I thought it would be easy to do what I want to do. Working longer days at the moment so I set up a doggie monitor to ensure the rascals aren’t tearing up the house.I got the web interface working, but the Pan-Tilt mech. has me quite bedeviled.

I noticed the problem when I tried to run “timeout.py” and IDLE 3 spit back an error message onto my screen. Something like, “‘module’ object has no attribute idle_timeout”. I also noticed that it was running Python 2, but it was easy to change the default program to 3. I really don’t know what difference it makes! I tried just deleting the line and running it, but it made the servos vibrate all crazy and I couldn’t get it to stop, so I had to reboot.

Anyhoo, I dug and dug in the swamps of sadness known as the file directory, and after having trod the desert of misunderstanding, I was able to locate something that resembled "the thing (init.py) that tells the stuff (Python scripts) that it’s okay to tell the other thing (Raspi) to do something (move the servos).

Alas, I found that the “distribution package”, I suspected, was lacking idle_timeout = pantilthat.idle_timeout. I looked at the github page under library, and it said that exactly the thing that it was lacking, was missing.
“PERFECT! GOTCHA! I’ll just add that line to the init file!”, I exclaimed. But the celebration was short lived as I attempted to save the changes I had just made. Permission was denied.

After several hours of trying to figure out what I needed to do, forgetting where the package was located, throwing something, traversing the swamp, retreading the desert, locating the thing again, still not figuring out what I need to do, I decided to start over and put a fresh Raspbian install on (in?) my Pi, just in case I unwittingly skipped a step in the first place…

…Didn’t work. Here’s what I did from the fresh install:

  1. update/ dist.upgrade, enable I2C, etc. followed by reboot
  2. shcurl -sS https://get.pimoroni.com/pantilthat | bash
  3. sudo apt-get install python3-pantilthat
  4. found init.py again and saw that the library still lacked the timeout line!

So, here I am, several days later at work and certainly a little balder. I figured out how to grant myself the permissions necessary to edit “init.py”, and remotely accessed the Pi, and added the line and finally saved it successfully. I’ll wait until I get home to try to run it because I don’t want any misbehaving, unstoppable servos throwing a party in my living room while I’m not there. If there’s a servo party I’d like to be there, you know?

TL;DR: I know something’s wrong, but what is it? Is it https://github.com/pimoroni/pantilt-hat.git, or how the terminal command retrieves the package for installation, me, or something else? I’m trying to learn how to integrate keyboard controls of pan/tilt into my Rpi-cam website, and it’s not going to be easy, so I want to be sure that the thing’s working right before I delve into it, because I won’t know if it’s not because I’m a neeeeeewb.


#2

shcurl was a typo. It was curl. I was wondering where those letters went. The end just said | ba. I typed the sh without looking for the errant letters. I am reckless.


#3

some examples require the very latest ‘cutting edge’ version of the library - this example certainly does.

You can install the library from the github repo directly by cloning it and then, from within the “library” folder, run:
sudo python3 ./setup.py install


#4

Do you mean within the “library” folder in which the Python folders are located?

As in:

cd /usr/lib (that’s where the python folders are with the pantilt scripts in them)

Followed by: sudo python3 ./setup.py install

I did get it to work by doing:

sudo idle3

^^That gave me permission to edit the scripts, so I opened them up and copied and pasted from the github library. I tried the cloning thing previously, but *screwed the pooch on it, because, you know, I don’t actually know what I’m doing… yet.

Not sure about that idiom’s origin, but in this context, it means that I did something wrong and it didn’t work, likely due to operator error.

Oh, and thanks for your response, by the way!


#5

no, you can touch up libraries in situ, but the preferred way would be to use the library as found in the repository:

git clone https://github.com/pimoroni/pantilt-hat
cd ./pantilt-hat/library
sudo python3 setup.py install

#6

Sweet. Thank you so much! Now I just have to learn how to use it…

Thanks again!
Yawwl are top-notch over there!