RPYC not working as a service
ajjack50n opened this issue · 9 comments
4.14.117-ev3dev-2.3.5-ev3
ii micropython-ev 2.1.0 all Python language bindings for ev3d
ii python3-ev3dev 1.2.0 all Python language bindings for ev3d
ii python3-ev3dev 2.1.0 all Python language bindings for ev3d
I am trying to follow instructions here for starting the RPYC service.
https://ev3dev-lang.readthedocs.io/projects/python-ev3dev/en/stable/rpyc.html
.. but I get the following error...
Exception has occurred: builtins.KeyError
('3047791664', u'SlaveService', u'rpyc.core.service')
========= Remote Traceback (1) =========
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/rpyc/core/protocol.py", line 305, in _dispatch_request
res = self._HANDLERS[handler](self, *args)
File "/usr/lib/python3/dist-packages/rpyc/core/protocol.py", line 539, in _handle_inspect
return tuple(netref.inspect_methods(self._local_objects[oid]))
File "/usr/lib/python3/dist-packages/rpyc/lib/colls.py", line 86, in __getitem__
return self._dict[key][0]
KeyError: (b'3047791664', 'SlaveService', 'rpyc.core.service')
File "/Users/andy/Documents/Python/non ev3 python scripts/myfirstRPyC.py", line 3, in <module>
conn = rpyc.classic.connect('192.168.2.2')
If I manually start using...
python rpyc_classic.py all is fine:)
I suspect I am doing something wrong but unsure what?
I should perhaps also say that I have ensure the version of RPYC on client and server is 4.1.5 and both are running python 2.x
Hmmm I haven't personally used RPyC, but you say you are using Python 2 yet the library on the EV3 is using Python 3. Is there a reason you intend to use Python 2?
I have switched to 3 and I still get the same result:( I have ensured again that client and server are running the same version of RPYC
Hmm, interesting. What version of RPyC is it? It seems like those line numbers are significantly different from what they are in the most recent release (4.1.15) and the file doesn't seem to have changed since 2019 so I'm inclined to believe this is an older version. Could you try a newer version on both ends? Perhaps uninstall rpyc via apt (sudo apt remove python3-rpyc
, I think) and then instead install via pip to ensure you have the latest: pip install rpyc
. We generally recommend using the apt version rather than pip but I doubt there's a more recent version available in the package archive.
Hey.. I have verified version 4.1.5 on client and server. Keep in mind that it I manually launch rpyc_classic.py it works. I have launched python3 on the device, imported rpyc and confirmed the version is 4.1.5. I have specified the version of python3 in exec start but still same result:(
I suppose I hadn't connected the dots to consider the fact that it works outside the service. Since you've tried explicitly using python3 in the service, that rules out a different interpreter. Perhaps it's an issue with the user account its running under (the service is presumably root
): could you try adding User=robot
to the service definition?
Hey brill.. that was it. User needs to be robot. I don't know if someone can update the docs on ev3dev site. All works great now! Thank you for your help!:)
Nice! Glad to hear it. I'm going to reopen this issue to remind myself to update the documentation
cool, might also be worth reminding people to ensure client and server versions match and that they opt for 2.x or 3.x on server and client.
Thanks again for help.