Slider NameError: name ‘pu’ is not defined

when I do this in my cmd, I get the following error:
Microsoft Windows [Version 10.0.26100.4351]
(c) Microsoft Corporation. All rights reserved.

C:\Users\rwolm>rm ~/.psychopy3/appData.cfg
‘rm’ is not recognized as an internal or external command,
operable program or batch file.

Where would I need to put the code?

Hello @Ange

rm is a comond line command used on Unix-systems to delete a file. On a Windows system you could use del. The folder structure is also different from a Unix system. You find the file under %APPDATA%\psychopy3.

Best wishes Jens

Thank you for your help. I managed to delete these files. However, it doesn’t fix the problem for me.

the variable ‘pu’ exists:


and is referenced in ‘labels’:

Still it gives me this error:

Running: C:\Users\rwolm\Desktop\Emo_reg_task\sliderTest_lastrun.py

96.6019 EXP Imported Quest.csv as conditions, 6 conditions, 2 params
96.6236 INFO Loaded monitor calibration from [‘2024_04_08 10:12’]
96.7024 EXP Imported Quest.csv as conditions, 6 conditions, 2 params
96.7154 INFO Loaded monitor calibration from [‘2024_04_08 10:12’]
96.8432 EXP Imported Quest.csv as conditions, 6 conditions, 2 params
Traceback (most recent call last):
File “C:\Users\rwolm\Desktop\Emo_reg_task\sliderTest_lastrun.py”, line 687, in
run(
File “C:\Users\rwolm\Desktop\Emo_reg_task\sliderTest_lastrun.py”, line 376, in run
labels=pu, ticks=(1, 10), granularity=0.0,
NameError: name ‘pu’ is not defined. Did you mean: ‘pi’?
6.8001 WARNING Stopping key buffers but this could be dangerous ifother keyboards rely on the same.
######## Experiment ended with exit code 1 [pid:16792] #########

I’m in python 2025.1.1.

Thank you so much!

The labels are set to constant and pu isn’t available at the start of the experiment.

Can that be changed to set each repeat? If not, then slider labels can’t easily be changed dynamically. I’m going to split this to a new thread because I don’t think it has any connection to the 2021 thread.

Unfortunately, I cannot change it to ‘set each repeat’ because the button is inactive. I cannot click on it. I’m in version 2025.1.1.

What I actually want to achieve is to use the slider, but I run into problems in the newer versions of psychopy. The last version where the slider works how I want it is version 2022.2.4 standalone. It does not work when being in the 2024 version and choosing an earlier version from the setting menu.

As always, thank you for your precious support!

on another computer with psychopy 2022.2.4, deleting the files appData.cfg and userPrefs.cfg doesn’t fix the problem. This is the error I get:

Running: C:\Users\Zz\Desktop\Emo_reg_task\images_task2_lastrun.py #######
2712.3316 EXP Imported Quest.xlsx as conditions, 6 conditions, 2 params
2712.3347 INFO Loaded monitor calibration from [‘2024_06_08 15:26’]
2712.3492 EXP Imported Quest.xlsx as conditions, 6 conditions, 2 params
pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)
Hello from the pygame community. Contribute - pygame wiki
1.6822 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\Zz\Desktop\Emo_reg_task\images_task2_lastrun.py”, line 172, in
labels=pu, ticks=(1,10), granularity=0.0,
NameError: name ‘pu’ is not defined
################ Experiment ended with exit code 1 [pid:13632] #################
2722.5392 EXP Imported Quest.xlsx as conditions, 6 conditions, 2 params
2722.5415 INFO Loaded monitor calibration from [‘2024_06_08 15:26’]

Thank you very much!

Hello @Ange

You get the same error message as before.

The error does not originate from either appData.cfg or userPrefs.cfg. Therefore, deleting these files will not solve your problem.

Are you trying to read the labels for your slider from a condition file? Is the column for the labels called pu? I am not sure but I am afraid that labels for a slider cannot be changed dynamically. I do not know whether this is possible in PsychoPy 2022.2.4.

Best wishes Jens

1 Like

Hi Jens,

yes

Yes

I did this already in this version. I don’t know why it is not working anymore. It was super simple. pu looks like this and the first part goes to the left side of the slider and the second part on the right side of the slider.

Hello @Ange

I have no idea why this used to work but doesn’t any more. You get the error message because the slider cannot dynamically change its labels.

Reading the labels from a condition file occurs after the slider has been constructed. PsychoPy reads the condition file when the trial is set up. Therefore, PsychoPy becomes informed of the label ‘pu’ when the trial is set up. However, the slider needs to know its labels when it is set up. However, the slider is set up before the trial is set up. Therefore, the slider does not yet recognise ‘pu’ because it only becomes available at a later stage of the experiment. The fact that the slider is set up before the trial also prevents dynamic labels for the slider.

Currently, the only solutions I can think of are to set up everything by hand or use Pavlovia surveys.

Best wishes Jens