gfx-hat icon indicating copy to clipboard operation
gfx-hat copied to clipboard

Examples fail to run with error "AttributeError: 'AsyncWorker' object has no attribute 'isAlive'"

Open aunitt opened this issue 3 years ago • 3 comments

After installing the code I get the following error:

Traceback (most recent call last): File "/home/pi/Pimoroni/gfxhat/examples/hello-world.py", line 55, in touch.on(x, handler) File "/usr/local/lib/python3.9/dist-packages/gfxhat/touch.py", line 119, in on register(handler) File "/usr/local/lib/python3.9/dist-packages/gfxhat/touch.py", line 114, in register _cap1166.on(channel=button, event='press', handler=handler) File "/usr/lib/python3/dist-packages/cap1xxx.py", line 386, in on self.start_watching() File "/usr/lib/python3/dist-packages/cap1xxx.py", line 400, in start_watching self.async_poll.start() File "/usr/lib/python3/dist-packages/cap1xxx.py", line 208, in start if self.isAlive() == False: AttributeError: 'AsyncWorker' object has no attribute 'isAlive' Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/cap1xxx.py", line 409, in stop_watching self.async_poll.stop() File "/usr/lib/python3/dist-packages/cap1xxx.py", line 213, in stop if self.isAlive() == True: AttributeError: 'AsyncWorker' object has no attribute 'isAlive' Exception ignored in: <function Cap1xxx.del at 0x76690460> Traceback (most recent call last): File "/usr/lib/python3/dist-packages/cap1xxx.py", line 522, in del File "/usr/lib/python3/dist-packages/cap1xxx.py", line 409, in stop_watching File "/usr/lib/python3/dist-packages/cap1xxx.py", line 213, in stop AttributeError: 'AsyncWorker' object has no attribute 'isAlive'

I've tried installing by running: sudo pip3 install gfxhat and curl https://get.pimoroni.com/gfxhat | bash and cloning the github repository and running: sudo python3 setup.py install

I did a pip install first.

It appears the pip install installs Cap1xxx 0.1.3, pip show Cap1xxx gives me: Name: Cap1xxx Version: 0.1.3 Summary: A module to drive various Microchip cap1xxx touch ICs Home-page: http://shop.pimoroni.com Author: Philip Howard Author-email: [email protected] License: MIT Location: /usr/lib/python3/dist-packages Requires: RPi.GPIO Required-by: gfxhat, touchphat, pianohat, ExplorerHAT, drumhat

Running sudo pip install Cap1xxx==0.1.4 got the example code to run.

aunitt avatar Mar 29 '22 13:03 aunitt

Thank you. I thought I'd caught all of these but Graphics HAT slipped my mind.

Gadgetoid avatar Mar 29 '22 13:03 Gadgetoid

Thanks aunitt! Your fix worked for me but took some finding. Seems like curl https://get.pimoroni.com/gfxhat | bash is unreliable.

gallanwood avatar Oct 20 '22 20:10 gallanwood

@Gadgetoid - I've just recieved my gfxhat for a project and the install script still isn't working correctly - I had to manually install Cap1xxx 0.1.4 as mentioned by @aunitt above.

Another small issue, when running any of the examples you now get the following:

/home/user/hello-world.py:31: DeprecationWarning: getsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use getbbox or getlength instead.

Change -

w, h = font.getsize(text)
x = (width - w) // 2
y = (height - h) // 2

To:

l, t, r, b = font.getbbox(text)
x = (width - r-l) // 2
y = (height - b) // 2

mmozzano avatar Feb 01 '23 14:02 mmozzano