vector-python-sdk
vector-python-sdk copied to clipboard
sdk examples loop error in Python 3.10
Error when running any sdk example in Python 3.10
As of 3.10, the *loop* parameter was removed from Event() since it is no longer necessary
I get this error in any sdk example only with Python 3.10. The previous versions work.
Is it a mistake on my side or just a missing udpate? If it is a missing update for the newer Python version, are there any plans of it being fixed in the near future?
I get the same error when using python 3.10. I think it because the sdk uses a deprecated parameters in asyncio since python 3.6 - 3.7. Please refer to this question on stackoverflow.
I'm not quite familiar with asyncio but maybe the best solution is to fork the repo and change the loop reference to get_event_loop() call
Change the following files (assuming you've used virtualenv to create venv):
cd <root_of_vector_project>
source venv/bin/active
Ok, now change the following lines (currently 77-79) in venv/lib/python3.10/site-packages/anki_vector/connection.py from:
self._granted_event = asyncio.Event(loop=loop)
self._lost_event = asyncio.Event(loop=loop)
self._request_event = asyncio.Event(loop=loop)
To:
self._granted_event = asyncio.Event()
self._lost_event = asyncio.Event()
self._request_event = asyncio.Event()
And also change venv/lib/python3.10/site-packages/anki_vector/events.py (currently line 133) from:
self._done_signal = asyncio.Event(loop=self._loop)
To:
self._done_signal = asyncio.Event()
Hope that helps!