Dollar sign in text box crashes Psychopy

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Ubuntu 20.04
PsychoPy version (e.g. 1.84.x): PsychoPy3, version 2021.2.3 (c)Jonathan Peirce 2018, GNU GPL license
Standard Standalone? (y/n) If not then what?: virtual environment
What are you trying to achieve?:
Assign variable to textbox in a text component: e.g., $some_text_to_display_depending_on_language_setting

What did you try to make it work?:
tried to enter the name of a str variable with a dollar sign prepended at the beginning

What specifically went wrong when you tried that?:
Psychopy crashed showing me this error message.

Traceback (most recent call last):
File “/path/to/my/home/directory/psychopy/lib/python3.8/site-packages/psychopy/app/builder/dialogs/”, line 29, in validate
validate(self, self.valType)
File “/path/to/my/home/directory/psychopy/lib/python3.8/site-packages/psychopy/app/builder/dialogs/”, line 442, in validate
val = str(obj.GetValue())
RecursionError: maximum recursion depth exceeded while calling a Python object

This is probably a bug but I am not entirely sure. Perhaps there is a reason why variables are not allowed in text boxes?

Please could you paste exactly what you wrote?


My “minimal reproducible example” would be this:

  • Launch PsychoPy environment by typing “source psychopy/bin/activate”

  • Start PsychoPy by typing “psychopy”. The GUI comes up now showing an empty routine named “trial”.

  • Click on the “Text” component in the right-hand panel.

  • Select first cursor position in the text box and hit “$”.

  • This gives me the error shown above.


Sorry – I don’t have any experience with running PsychoPy in virtual environments.

I seem to remember a similar bug cropping up and being fixed in a version since 2021.2.3; the error is essentially that the code which checks for dollar signs calls the function within itself under some very specific conditions so ends up in an infinite loop, which wx (the Python package which the PsychoPy app interface is built on) terminates after a set limit.

If you update to the latest version (2022.1.3 at time of writing) does the error persist?

Hi all,

I believe an exact problem is as below, right?

a probably temporary solution

My OS: Ubuntu 18.04
Installed Psychopy through pip install psychopy

Conda Environment:
python 3.8.13 ha86cf86_0_cpython conda-forge
psychopy 2022.2.4 pypi_0 pypi
wxpython 4.1.1 pypi_0 pypi

I just installed a 2022.2.4 version of Psychopy today (on 22 August, 2022) and I still encountered this error in my environment as well (2021 version works fine in another conda environment). See below error messages.

Error messages on the Psychopy3 output console

Traceback (most recent call last):
  File ".../anaconda3/envs/psychopy2022/lib/python3.8/site-packages/psychopy/app/builder/dialogs/", line 31, in validate
    validate(self, self.valType)
  File ".../anaconda3/envs/psychopy2022/lib/python3.8/site-packages/psychopy/app/builder/dialogs/", line 557, in validate
    if re.findall(r"(?<!\\)\"", val):
  File ".../anaconda3/envs/psychopy2022/lib/python3.8/", line 241, in findall
    return _compile(pattern, flags).findall(string)
  File ".../anaconda3/envs/psychopy2022/lib/python3.8/", line 291, in _compile
    if isinstance(flags, RegexFlag):
RecursionError: maximum recursion depth exceeded while calling a Python object

**Error message on Terminal: **

(psychopy:23502): Gtk-WARNING **: 16:59:16.520: Invalid text buffer iterator: either the iterator is uninitialized, or the characters/pixbufs/widgets in the buffer have been modified since the iterator was created.
You must use marks, character numbers, or line numbers to preserve a position across buffer modifications.
You can apply tags and insert marks without invalidating your iterators,
but any mutation that affects 'indexable' buffer contents (contents that can be referred to by character offset)
will invalidate all outstanding iterators
Segmentation fault (core dumped)

I typed a “variable name” without a $ sign without “” double quotations (e.g. sbj_num, which is defined earlier) in coder and it works, but it would be more convenient if I can use a $ sign in builder.


Hi @ht_cog_neuro,

I have not seem this error using this installation procedure.
Nevertheless, I’ve used Ubuntu 22.04 there.
But, as I don’t remember seeing this error in Ubuntu 20.04 either, it might be an OS version issue.

Edit: I don’t remember seeing this in Ubuntu 20.04 with newer versions of Psychopy.

Best regards,

Hi Bastosfh,

I find a work around by installing version 2022.1.4, not 2022.2.4 as you suggested.


Same here with 2023.1.1 PsychoPy and Ubuntu 22.04