It’s been now a few months since I did this experiment. I used the code that you can find on Pupil Lab website https://docs.pupil-labs.com/#developer-docs but I ran the code on a separate python program (not directly from Psychopy) and was receiving the data on a separate port.
Here what I used to record the ‘gaze’.
Hope this helps.
from msgpack import loads
context = zmq.Context()
# open a req port to talk to pupil
addr = '127.0.0.1' # remote ip or localhost
req_port = "50020" # same as in the pupil remote gui
req = context.socket(zmq.REQ)
# ask for the sub port
sub_port = req.recv_string()
# open a sub port to listen to pupil
sub = context.socket(zmq.SUB)
# set subscriptions to topics
# recv just pupil/gaze/notifications
# sub.setsockopt_string(zmq.SUBSCRIBE, 'gaze')
# sub.setsockopt_string(zmq.SUBSCRIBE, 'notify.')
# sub.setsockopt_string(zmq.SUBSCRIBE, 'logging.')
# or everything:
# sub.setsockopt_string(zmq.SUBSCRIBE, '')