Working experiment from last spring now crashes on startup

OS Win10
PsychoPy version The last successfully run experiment used psychopy 2021.2.3 according to its data file. The current version downloaded in the system information says 2022.1.2, though we have never manually updated the experiment. Manually telling psychopy to use 2021.2.3 seems to reduce the number of error messages but does not resolve the problem.

Standard Standalone? Yes
What are you trying to achieve?: Last Spring we were using a psychopy experiment that was partially made in builder and has its own custom code that we used successfully for several experimental sessions. The last session was run around 5/22 and we have not touched it since. However, upon trying to run the same files now in 10/22, the experiment crashes before you can even set the global experimental settings.

What did you try to make it work?: I have tried to manually make psychopy use the same version as was in the last recorded data file. This seemed to reduce the number of error messages but did not resolve the issue. We used this same experimental file over several (7+) months without issue so I am unsure if this is a version problem or something new.

What specifically went wrong when you tried that?:
Here is the runner error code:

Generating PsychoPy script...
## Running: C:\Users\username\Dropbox\Lab\F32-TL1\Psycho_Py\GASI_Control_lastrun.py ##
54.6728     EXP     Imported Conditions.xlsx as conditions, 2 conditions, 3 params
54.6789     WARNING     Monitor specification not found. Creating a temporary one...
54.7471     EXP     Imported Conditions.xlsx as conditions, 2 conditions, 3 params
pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)
Hello from the pygame community. https://www.pygame.org/contribute.html
10.4634     WARNING     We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use ['sounddevice', 'PTB', 'pyo', 'pygame'] (in that order).
Traceback (most recent call last):
  File "C:\Users\username\Dropbox\Lab\F32-TL1\Psycho_Py\GASI_Control_lastrun.py", line 40, in <module>
    expInfo = {'participant': '', 'session': '', 'Sides': [LR, RL], 'Initials': ''}
NameError: name 'LR' is not defined
################ Experiment ended with exit code 1 [pid:33000] #################
86.0604     EXP     Imported Conditions.xlsx as conditions, 2 conditions, 3 params
86.0742     WARNING     Monitor specification not found. Creating a temporary one...

The exit code 1 always stays the same, but the pid is always different. The " name ‘LR’ is not defined’ " part seems to be the final crash but the experiment info popup, which normally appears when we run the program to define the variable ‘Sides,’ does not show up. I also can’t remember if it always tried to call the lastrun.py file or not. When I’m trying to run the program it should be initiating a new run, not calling the previous run.

Any help identifying this issue would be appreciated.

Hi @aarsmith,

In the experiment info popup, could you try setting the possible values for Sides to ["LR", "RL"]? Without the quotation marks around these values, PsychoPy will be looking for a variable called LR or RL.

Thanks,

Kim

@Kimberley_Dundas That did appear to fix the issue and I can at least enter the experiment (though it was never a problem previously), but new problems are now present. In particular, once a movie loads and starts playing there is considerable lag and the sound is no longer synced. However, the movie plays through, I pause it briefly, and then use Moviestim.stop. The experiment then enters enters the next module which has a slider where participants report their happiness with what they just saw and it reloads the movie that just played (loadMovie) to allow for repeats on the next trial. Pyschopy appears to crash just as its generating the slider which could coincide with reloading the movie. The psychopy runner also freezes for considerable time before generating its report below:

Traceback (most recent call last):
File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py", line 385, in _updateFrameTexture
self._numpyFrame = self._mov.get_frame(self._nextFrameT)
File "<decorator-gen-11>", line 2, in get_frame
File "C:\Program Files\PsychoPy\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "C:\Program Files\PsychoPy\lib\site-packages\moviepy\Clip.py", line 93, in get_frame
return self.make_frame(t)
File "C:\Program Files\PsychoPy\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 113, in <lambda>
self.make_frame = lambda t: self.reader.get_frame(t)
File "C:\Program Files\PsychoPy\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 184, in get_frame
result = self.read_frame()
File "C:\Program Files\PsychoPy\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 133, in read_frame
raise IOError(("MoviePy error: failed to read the first frame of "
OSError: MoviePy error: failed to read the first frame of video file SevS\NearMiss\SevS_NearMiss_6.mp4. That might mean that the file is corrupted. That may also mean that you are using a deprecated version of FFMPEG. On Ubuntu/Debian for instance the version in the repos is deprecated. Please update to a recent version from the website.

The above error repeats several times and is followed by this one that references reloading the movie:

Traceback (most recent call last):
File "C:\Users\gas_team\Desktop\PsychoPy\GASI_Experimental_lastrun.py", line 1054, in <module>
Movie.loadMovie(Movie.name)
File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py", line 256, in loadMovie
self._updateFrameTexture()
File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py", line 391, in _updateFrameTexture
self._updateFrameTexture()
File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py", line 391, in _updateFrameTexture
self._updateFrameTexture()
File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py", line 391, in _updateFrameTexture
self._updateFrameTexture()
[Previous line repeated 975 more times]
File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movie3.py", line 385, in _updateFrameTexture
self._numpyFrame = self._mov.get_frame(self._nextFrameT)
File "<decorator-gen-11>", line 2, in get_frame
File "C:\Program Files\PsychoPy\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "C:\Program Files\PsychoPy\lib\site-packages\moviepy\Clip.py", line 93, in get_frame
return self.make_frame(t)
File "C:\Program Files\PsychoPy\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 113, in <lambda>
self.make_frame = lambda t: self.reader.get_frame(t)
File "C:\Program Files\PsychoPy\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 184, in get_frame
result = self.read_frame()
File "C:\Program Files\PsychoPy\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 123, in read_frame
warnings.warn("Warning: in file %s, "%(self.filename)+
File "C:\Program Files\PsychoPy\lib\warnings.py", line 109, in _showwarnmsg
sw(msg.message, msg.category, msg.filename, msg.lineno,
File "C:\Program Files\PsychoPy\lib\logging\__init__.py", line 2186, in _showwarning
logger.warning("%s", s)
File "C:\Program Files\PsychoPy\lib\logging\__init__.py", line 1458, in warning
self._log(WARNING, msg, args, **kwargs)
File "C:\Program Files\PsychoPy\lib\logging\__init__.py", line 1587, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args,
File "C:\Program Files\PsychoPy\lib\logging\__init__.py", line 1556, in makeRecord
rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
File "C:\Program Files\PsychoPy\lib\logging\__init__.py", line 314, in __init__
if (args and len(args) == 1 and isinstance(args[0], collections.abc.Mapping)
File "C:\Program Files\PsychoPy\lib\abc.py", line 98, in __instancecheck__
return _abc_instancecheck(cls, instance)
RecursionError: maximum recursion depth exceeded in comparison
pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)

The above error is followed by several video catchup and missing frame warnings such as:

16.3665 WARNING 0.6964206999982707: Video catchup needed, advancing self._nextFrameT from 0.0 to 0.03336666666666667
68.1115 WARNING Frame 6.87353333333335 not found, moving one frame and trying again

The videos play fine on windows media player and do still play in psychopy the first time (before it crashes), so I’m wondering if there is a problem with reloading the video? All videos are .mp4s of approximately 3.3 MB size and, as I had previously mentioned, played and reloaded fine this past spring.

I realize that was a ton of information but if you can point to any other troubleshooting ideas I would greatly appreciate it!

Hi @aarsmith,

No problem at all, the more info the better!

Could I just check, when you say there was custom code added to the experiment is that custom code added in code components or have you edited the experiment in Coder view?

Thanks,

Kim

@Kimberley_Dundas It was added using code components. No source code was altered.

Would you mind attaching your experiment here so that I can take a quick look?

Thanks so much,

Kim

@Kimberley_Dundas Sure thing, thanks for taking a look. There’s actually two versions of the task (E and C) where C was built from a working version of E and largely shares the same code. To me, they seem to be crashing due to slightly different reasons but it could maybe be helpful so i am uploading them both. I also have their accompany files they draw from on hand but wasn’t sure how to upload to this site.

GASI_Experimental.psyexp (54.1 KB)
GASI_Control.psyexp (49.8 KB)

Hi @Kimberley_Dundas, any luck thinking of anything? I’ve actually gotten the experimental version to work by reverting to an old psychopy version (2021.2.0). Oddly, though, the control (C) version still does not work despite sharing 90% of the same code with the E version.

The cause of the crashing still appears to be similar. The movie lags slightly before starting and the sound is de-synced, which is a perfect cue for the experiment to lag and crash upon trying to implement the slider in the SWB routine. Are there potentially any solutions to allow the movie to buffer or alter the coding of that in some way?

I’m sure you’re busy, so thanks for taking the time.

Hi @aarsmith,

So sorry for the delay here!

I’ve just taken a look through your .psyexp file for the E version. I can see from your file that although you’re using Builder view to design your experiment which is great, you’re using only code components rather than built-in Builder components within that (apart from the slider). In theory this is fine but it does mean that when there are major updates to PsychoPy, you need to go in manually and change the code (for example Movie to MovieStim etc.). This might be advice that’s a bit redundant now but worth noting.

Have you tried using MovieStim instead of Movie? There were major updates to improve the performance of this, especially around pausing/reloading etc. Although I’m curious as to why this wouldn’t happen in your E version but would in your C version.