psychopy.org | Reference | Downloads | Github

Importing certain iohub modules failed with the latest psychopy installation

As stated in the title, I get importing error even with the iohub demos packaged within:-

Running: D:\Program Files\PsychoPy2\lib\site-packages\psychopy\demos\coder\iohub\ioHubDelayTest\run.py

Traceback (most recent call last):
File “D:\Program Files\PsychoPy2\lib\site-packages\psychopy\demos\coder\iohub\ioHubDelayTest\run.py”, line 21, in
from psychopy.iohub import Computer, ioHubExperimentRuntime, EventConstants
ImportError: cannot import name ioHubExperimentRuntime

EventConstants (and possibly others which I haven’t quite figured out?) also seem to be missing. Any idea if this is just me, or are people getting this as well?

1 Like

Hi Aaron, I’m encountering a very similar problem when I try to run a script that includes importing ioHubExperimentRuntime. Were you able to solve this? Thanks so much for any help.

Were you getting “importError: cannot import name ioHubExperimentRuntime” or something like that?

If your method of calling module imports is based on (or something like) this old eyetracking test script - which I am doing at the moment (run.py) from github https://github.com/psychopy/psychopy/blob/master/psychopy/demos/coder/iohub/eyetracking/selectTracker/run.py , this particular import I think, might be a problem:-

from psychopy.iohub import (EventConstants, EyeTrackerConstants, 
getCurrentDateTimeString, ioHubExperimentRuntime)

I was looking into the .py files in psychopy.iohub and realised that EventConstants and EyeTrackerConstants are in the constant.py file, but not getCurrentDateTimeString and ioHubExperimentRuntime. I think something got shifted around during updates?

I had to change it to the following in order to successfully import EventConstants and EyeTrackerConstants:

from psychopy.iohub.constants import (EventConstants, EyeTrackerConstants)

getCurrentDateTimeString and ioHubExperimentRuntime doesn’t seem be in the constant.py script, and I can’t seem to locate it at the moment. Perhaps @jon or @sol knows where we can properly import these two modules from to get them to work?

EDIT: Found the update notes for iohub here: https://github.com/psychopy/psychopy/blob/master/psychopy/iohub/release_notes.rst

Is there a recent iohub demo that we can refer to in the light of the recent changes? Because the run.py file that was uploaded 5 months ago onto github seems to be outdated, and does not reflect many of the changes listed on the patch notes.

2 Likes

Any updates on this? The current iohub demos do not work, giving the following error:

ImportError: cannot import name ioHubExperimentRuntime

But I can’t find ioHubExperimentRuntime to try to change the import for myself.

Hi there,

iohub modules have been changed dramatically from psychopy version 1.86 onwards as far as I am aware of, but the iohub demos were not updated accordingly. There are not a lot of comprehensive resources online at the moment on how to work with the new updates apart from needing to wait for the “Programming Experiments in Python” book (which revolves around coding with psychopy) that will only be out in 2019-2020.

My current solution is to actually downgrade your psychopy version to 1.85.4 and below (1.85.4 works for me at the moment) if you wish to work with the old codes.

Hi,
does anyone have working examples of ioHub process with PsychoPy 1.90.+ ?
ioHub demos are not working on my windows 10 machine giving similar import errors. The same is with my previously working experimental procedures codes.

I’m using ioHub for connecting with eye trackers.
It is really frustrating that the update in the basic usage is done with very insufficient documentation.

Just a heads-up, I did a text search in the PsychoPy library files. It looks like all mention of ioHubExperimentRuntime got completely purged from the later versions of PsychoPy (both 2.7 and 3), except for the demos. In other words, all 5 demos that rely on the module are broken. The demos are:

elotouchscreen
remoteevents
ioHubDelayTest
analoginput
eyetracking/selectTracker and eyetracking/gcCursor

@jon, should the demos be removed, or is it planned that the iohub support will be re-added at a later point?

1 Like

Hello,

Is there any update on the ioHub process with PsychoPy 1.90.3 or more recent?
If not, any recommendations for a new programmer getting eye tracking to work in PsychoPy?

2 Likes

Sorry for the late reply.

I suggest getting to know pylink. Check out the official sr-forum documentation:
https://www.sr-support.com/forum/how-tos/getting-started/getting-started-with-experimental-programming/52242-getting-started-with-psychopy

It’s now much better supported than before.

Hi everyone, Hi @angjw.aaron an @egorananyev,

Is this problem already resolved? I get the same errors when using the stroop example from the iohub github. I use psychopy 3.1.2 through anaconda based on python 3.6 on an MAcOSX (el capitan).

I know about pylink, but I wanted to explore iohub as it might be easier to incorporate in builder based experiments.

There is no longer active support for the iohub module. I suggest using pylink instead - it is actually not too difficult to use once you get a hang of it. Attached is a really simple pylink experiment script (programmed on python 2.7; using Eyelink) that I hope, would be useful in helping you get started. It consist of 3 trials of reaction time task that starts off with a fixation cross. A gabor patch will appear after some time at random and the task is to blink the eye immediately when the patch appears.

simple_track.py (13.2 KB)

1 Like

@angjw.aaron Thank you so much for the effort to post the example! That is super helpful and similar to a task I wan to implement! I indeed figured that I should stick with pylink. The demo’s from SR Research work. It probably now just comes down on my newbie python programming skills :grimacing:

Where did you find that support for iohub is discontinued btw? It wasn’t clear on github from a first glance for example.

@sol was the one who came up with the iohub module. He mentioned that he is currently doing something else and has moved on from supporting iohub.

@angjw.aastron, I spent a lot of time getting iohub running with Python 3.5+ and PsychoPy3 in a month or so ago. The currently supported eye trackers are GazePoint GP3, SR Research EyeLink 1000 +, and Tobii systems. I have tested the eye trackers on Windows only.

All remaining iohub Coder demos should now work as well.

With that said I am sure there are some bugs that I have not come across.

There is an issue with iohub + macOS + Builder that causes iohub to fail to launch that I have not been able to look at or fix. If you build the project script and run it from anaconda it works.

I do not think anyone said iohub is no longer supported. @jon would be the one to make that call I think. I do my best, which does mean sometimes I miss PsychoPy discourse support posts because I’m focused on other obligations. This would get better if others who had a supported eye tracker also started helping support iohub a bit - I’m only 1 person with a limited set of hardware. :wink:

1 Like

I’m keen that ioHub continues to be supported, within whatever time that Sol has to dedicate to it. I think it’s fair to say that, yes, there was a period where the support wasn’t possible but lately ioHub has been getting a lot of love (thanks Sol). Some of the recent fixes have not been released yet but look out for the 3.2 release with more iohub updates

Ahhhh apologies @sol . I had the impression that your personal obligations (mentioned some time before, somewhere) made it difficult for you to maintain iohub over the last year or so and thought you moved on completely! Personally glad that this project wasn’t abandoned as a bulk of my scripts utilises iohub.

Hi Jon & @sol:

I’m looking for help to get the zmq networking function to work properly with pupil-labs eye trackers. I think network.remoteeventsubscriber and network.eventpublisher modules do not load in iohub currently. (Using Windows 10, standalone v 3.1.5 Psychopy). The pupil-labs eye tracker communication is through the zmq pub/sub method just like the network.removeeventsubscriber method appears to support. However the network module output doesn’t appear to appear in the HDF file. I’ve used nearly the default templates from default_eventpublisher.yaml (the publisher module is required for subscriber according to Sol’s header document) and default default_remoteeventsubscriber.yaml template and put them into my own ioconfig.yaml file.

In the resulting HDF file from my behavioral paradigm, the data event store listeners don’t appear to save network events (the class_id’s in the class_table_mapping do not include ID’s 60,61 which are the network module IDs).

The .yaml file I pass to ioHubConnection provides the following dictionary which I confirmed through ioHubConnection.getHubServerConfig():

{‘network.EventPublisher’: {‘name’: ‘evt_pub’, ‘monitor_event_types’: [], ‘publishing_protocal’: ‘tcp://*:5555’, ‘enable’: True, ‘save_events’: True, ‘stream_events’: True, ‘auto_report_events’: True, ‘event_buffer_length’: 128, ‘manufacturer_name’: ‘N/A’, ‘device_number’: ‘N/A’, ‘serial_number’: ‘N/A’, ‘manufacture_date’: ‘DD-MM-YYYY’, ‘model_name’: ‘N/A’, ‘model_number’: ‘N/A’, ‘software_version’: ‘N/A’, ‘hardware_version’: ‘N/A’, ‘firmware_version’: ‘N/A’}, ‘network.RemoteEventSubscriber’: {‘name’: ‘pupil_sub’, ‘monitor_event_types’: [‘gaze.’], ‘subscription_protocal’: ‘tcp://127.0.0.1:50020’, ‘remote_iohub_address’: [‘127.0.0.1’, 50020], ‘enable’: True, ‘save_events’: True, ‘stream_events’: True, ‘auto_report_events’: True, ‘event_buffer_length’: 128, ‘manufacturer_name’: ‘pupil_labs’, ‘device_number’: ‘N/A’, ‘serial_number’: ‘N/A’, ‘manufacture_date’: ‘08-01-2019’, ‘model_name’: ‘Core’, ‘model_number’: 1, ‘software_version’: ‘pupil_capture’, ‘hardware_version’: ‘N/A’, ‘firmware_version’: ‘N/A’}, ‘monitor_devices’: [{‘Display’: {‘name’: ‘display’, ‘reporting_unit_type’: ‘deg’, ‘device_number’: 0, ‘physical_dimensions’: {‘width’: 286, ‘height’: 179, ‘unit_type’: ‘mm’}, ‘default_eye_distance’: {‘surface_center’: 480, ‘unit_type’: ‘mm’}, ‘psychopy_monitor_name’: ‘default’}}, {‘Keyboard’: {‘name’: ‘keyboard’}}, {‘Mouse’: {‘name’: ‘mouse’, ‘enable’: True, ‘monitor_event_types’: [‘MouseMoveEvent’, ‘MouseDragEvent’, ‘MouseScrollEvent’, ‘MouseButtonPressEvent’, ‘MouseButtonReleaseEvent’, ‘MouseMultiClickEvent’], ‘save_events’: True, ‘stream_events’: True, ‘auto_report_events’: True, ‘event_buffer_length’: 256, ‘device_number’: 0, ‘serial_number’: ‘N/A’, ‘manufacture_date’: ‘DD-MM-YYYY’, ‘manufacturer_name’: ‘N/A’, ‘model_name’: ‘N/A’, ‘model_number’: ‘N/A’, ‘software_version’: ‘N/A’, ‘hardware_version’: ‘N/A’, ‘firmware_version’: ‘N/A’}}, {‘Experiment’: {‘name’: ‘experimentRuntime’}}], ‘data_store’: {‘enable’: True, ‘experiment_info’: {‘code’: ‘ystart’, ‘experiment_id’: 1, ‘title’: ‘’, ‘description’: ‘’, ‘version’: ‘’, ‘total_sessions_to_run’: 0}, ‘session_info’: {‘code’: ‘S_2019_Aug_11_1328’, ‘name’: ‘’, ‘comments’: ‘’, ‘user_variables’: {}, ‘session_id’: 1}, ‘filename’: ‘data\S_2019_Aug_11_1328’, ‘multiple_experiments’: False, ‘flush_interval’: 32}, ‘global_event_buffer’: 2048, ‘udp_port’: 9034, ‘windows_msgpump_interval’: 0.001, ‘log_raw_kb_mouse_events’: False, ‘coverage_env_var’: ‘None’}

So I know the .yaml file is providing the correct information, but there doesn’t appear to be any network events, is there a simple fix to get the iodatastore to save the network events?

Thanks!
Linus

iohub no longer supports the network device, it was not ported to Python 3 / PsychoPy 3.

For a list of supported iohub devices in Python 3 / PsychoPy3 please see https://www.psychopy.org/api/iohub.html

Thank you.