Psychopy 3 Error Broken Plugin Environment

OS (e.g. Win10): Windows 11
PsychoPy version (e.g. 2024.2.4 Py 3.8): 2024.2.4
Standard Standalone Installation? (y/n) IYes
Do you want it to also run online? (y/n) Yes
What are you trying to achieve?: I am trying to run my experiment but i keep getting stuck on this Type Error message when i trying to click a button with my mouse. It seems mouse component Clickable stimuli can’t detect the name of my button in that routine at runtime

What specifically went wrong when you tried that?:
It gives me this error message whenever I use my mouse component to click a button. I dont understand why it’s not working; it should work. I would appreciate the help here.

TypeError: Cannot read properties of undefined (reading ‘contains’)
at Scheduler._currentTask (CogExperiment_Audiov4.js:886:23)
at Scheduler._runNextTasks (Scheduler.js:233:24)
at Scheduler._runNextTasks (Scheduler.js:240:37)
at Scheduler._runNextTasks (Scheduler.js:240:37)
at update (Scheduler.js:139:29)

Here is the JavaScript Code : var estimateMaxDurationReached;
var gotValidClick;
var estimateMaxDuration;
var estimateComponents;
function estimateRoutineBegin(snapshot) {
return async function () {
TrialHandler.fromSnapshot(snapshot); // ensure that .thisN vals are up to date

//--- Prepare to start Routine 'estimate' ---
t = 0;
frameN = -1;
continueRoutine = true; // until we're told otherwise
// keep track of whether this Routine was forcibly ended
routineForceEnded = false;
estimateClock.reset();
routineTimer.reset();
estimateMaxDurationReached = false;
// update component parameters for each repeat
type_box.setText('');
type_box.refresh();
type_box.setText('');
// setup some python lists for storing info about the mouse_1
// current position of the mouse:
mouse_1.x = [];
mouse_1.y = [];
mouse_1.leftButton = [];
mouse_1.midButton = [];
mouse_1.rightButton = [];
mouse_1.time = [];
mouse_1.clicked_name = [];
gotValidClick = false; // until a click is received
mouse_1.mouseClock.reset();
psychoJS.experiment.addData('estimate.started', globalClock.getTime());
estimateMaxDuration = null
// keep track of which components have finished
estimateComponents = [];
estimateComponents.push(type_box);
estimateComponents.push(text);
estimateComponents.push(mouse_1);
estimateComponents.push(next_btn);
estimateComponents.push(next_text);

for (const thisComponent of estimateComponents)
  if ('status' in thisComponent)
    thisComponent.status = PsychoJS.Status.NOT_STARTED;
return Scheduler.Event.NEXT;

}
}

var prevButtonState;
var _mouseButtons;
var _mouseXYs;
var _pj;
function estimateRoutineEachFrame() {
return async function () {
//— Loop for each frame of Routine ‘estimate’ —
// get current time
t = estimateClock.getTime();
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
// update/draw components on each frame

// *type_box* updates
if (t >= 0.0 && type_box.status === PsychoJS.Status.NOT_STARTED) {
  // keep track of start time/frame for later
  type_box.tStart = t;  // (not accounting for frame time here)
  type_box.frameNStart = frameN;  // exact frame index
  
  type_box.setAutoDraw(true);
}


// if type_box is active this frame...
if (type_box.status === PsychoJS.Status.STARTED) {
}


// *text* updates
if (t >= 0.0 && text.status === PsychoJS.Status.NOT_STARTED) {
  // keep track of start time/frame for later
  text.tStart = t;  // (not accounting for frame time here)
  text.frameNStart = frameN;  // exact frame index
  
  text.setAutoDraw(true);
}


// if text is active this frame...
if (text.status === PsychoJS.Status.STARTED) {
}

// *mouse_1* updates
if (t >= 0.0 && mouse_1.status === PsychoJS.Status.NOT_STARTED) {
  // keep track of start time/frame for later
  mouse_1.tStart = t;  // (not accounting for frame time here)
  mouse_1.frameNStart = frameN;  // exact frame index
  
  mouse_1.status = PsychoJS.Status.STARTED;
  prevButtonState = mouse_1.getPressed();  // if button is down already this ISN'T a new click
}

// if mouse_1 is active this frame...
if (mouse_1.status === PsychoJS.Status.STARTED) {
  _mouseButtons = mouse_1.getPressed();
  if (!_mouseButtons.every( (e,i,) => (e == prevButtonState[i]) )) { // button state changed?
    prevButtonState = _mouseButtons;
    if (_mouseButtons.reduce( (e, acc) => (e+acc) ) > 0) { // state changed to a new click
      // check if the mouse was inside our 'clickable' objects
      gotValidClick = false;
      mouse_1.clickableObjects = eval(/* next_btn */
      )
      ;// make sure the mouse's clickable objects are an array
      if (!Array.isArray(mouse_1.clickableObjects)) {
          mouse_1.clickableObjects = [mouse_1.clickableObjects];
      }
      // iterate through clickable objects and check each
      for (const obj of mouse_1.clickableObjects) {
          if (obj.contains(mouse_1)) {
              gotValidClick = true;
              mouse_1.clicked_name.push(obj.name);
          }
      }
      // check if the mouse was inside our 'clickable' objects
      gotValidClick = false;
      mouse_1.clickableObjects = eval(/* next_btn */
      )
      ;// make sure the mouse's clickable objects are an array
      if (!Array.isArray(mouse_1.clickableObjects)) {
          mouse_1.clickableObjects = [mouse_1.clickableObjects];
      }
      // iterate through clickable objects and check each
      for (const obj of mouse_1.clickableObjects) {
          if (obj.contains(mouse_1)) {
              gotValidClick = true;
              mouse_1.clicked_name.push(obj.name);
          }
      }
      if (gotValidClick === true) { 
        _mouseXYs = mouse_1.getPos();
        mouse_1.x.push(_mouseXYs[0]);
        mouse_1.y.push(_mouseXYs[1]);
        mouse_1.leftButton.push(_mouseButtons[0]);
        mouse_1.midButton.push(_mouseButtons[1]);
        mouse_1.rightButton.push(_mouseButtons[2]);
        mouse_1.time.push(mouse_1.mouseClock.getTime());
      }
      if (gotValidClick === true) { // end routine on response
        continueRoutine = false;
      }

Hi There,

Could you please share s .psyexp file with a minimal demo of the bug?

What are the settings in the basic tab and the data tab of your mouse component?

Thanks,

Becca

Hi

Nevermind i solved this issue, it was just a formatting error.

Also i keep getting this message in .psyexp files. I have tried deleting my psychopy 3 foolder. Uninstall the software and install it again. but it becoming really annoying. The Psychopy plugin environment is really buggy.

Traceback (most recent call last):
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\builder\builder.py”, line 1434, in pilotFile
self.app.runner.panel.pilotLocal(event)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\runner\runner.py”, line 659, in pilotLocal
self.runLocal(evt, args=[“–pilot”], focusOnExit=focusOnExit)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\runner\runner.py”, line 641, in runLocal
generateScript(
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 60, in generateScript
exp.saveToXML(filename=exp.filename)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment_experiment.py”, line 558, in saveToXML
legacy = self.sanitizeForVersion(self.settings.params[‘Use version’].val)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment_experiment.py”, line 502, in sanitizeForVersion
targetVersion = Version(targetVersion)
File “C:\Program Files\PsychoPy\lib\site-packages\packaging\version.py”, line 200, in init
raise InvalidVersion(f"Invalid version: ‘{version}’")
packaging.version.InvalidVersion: Invalid version: ‘latest’

Are you selecting “latest” in Experiment Settings / Use version? I would recommend that you leave that field blank.