Can't save experiment in builder in ubuntu

OS Ubuntu 21.04
PsychoPy version 2021.2.0
Standard Standalone? (n)
What are you trying to achieve?: Trying to save a new experiment file created in builder

What did you try to make it work?: Opened psychopy, clicked ‘save current experiment as…’ button. Reboot, repeat. Tried also changing psychopy version in the settings.

What specifically went wrong when you tried that?:
When I click save experiment I get this error:

Traceback (most recent call last):
File “/home/jay/.local/lib/python3.9/site-packages/psychopy/app/builder/”, line 772, in fileSaveAs
self.fileSave(event=None, filename=newPath)
File “/home/jay/.local/lib/python3.9/site-packages/psychopy/app/builder/”, line 731, in fileSave
filename = self.exp.saveToXML(filename)
File “/home/jay/.local/lib/python3.9/site-packages/psychopy/experiment/”, line 329, in saveToXML
self.xmlRoot = self.xml
File “/home/jay/.local/lib/python3.9/site-packages/psychopy/experiment/”, line 314, in xml
File “/usr/lib/python3.9/xml/etree/”, line 244, in append
File “/usr/lib/python3.9/xml/etree/”, line 266, in _assert_is_element
raise TypeError(‘expected an Element, not %s’ % type(e).name)
TypeError: expected an Element, not Element

I don’t know if this is related or not, but there is also an font error saying " “WARNING /home/jay/.psychopy3/fonts/Consolas.truetype doesn’t have valid font family name”"

1 Like

Do you have code looking for .name of something? If so, try removing it. I’d recommend posting the relevant code component here and what you expected it to do.

Hi, thanks for that. It happens with a completely blank experiment, as well as opening demo experiments and clicking save on them. So it’s not a variable that I’ve added.

I just noticed an additional font error message in the runner, which I don’t know if it’s related.
“WARNING /home/jay/.psychopy3/fonts/Consolas.truetype doesn’t have valid font family name”

Try installing 2021.2.1

It might be a failed installation.

Thanks that was it!
pip uninstall psychopy; pip install psychopy
and it’s working fine.

Thanks for your help!

Opps, spoke to soon. That didn’t work.

What I’ve figured out is that if I install following the recommended way:
pip install psychopy
Then psychopy 2021.2.0 installs, and works apart from not being able to save.

If I install from the outdated ubuntu package, using: sudo apt install psychopy
Then the outdated package, psychopy 2020.2.1 is installs, and has a host of errors, but can save files.
I see that there are a lot of posts in the forum about difficulty installing in ubuntu. Is it currently understood to work or to be broken?
I’ll try an conda install next, but am curious if others have got it to work recently.

Thanks for any advice

I can confirm that I can’t install via conda either. I see this is an issue others are having (e.g., PsychoPy install on 20.04 deprecated library ).

Should I persist or is it known to be broken on linux?


Hi everyone, have there been any developments on this? I am having the same issue when trying to install the new version 2021.2.3 on Ubuntu. However, 2021.1.4 is working fine. I can continue using the old version, but would be nice to know if there is a solution to this.

1 Like (48.7 KB)

Hi all, I had the same problem with Psychopy2021.2.3 on Debian Linux (Linux bll4 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) x86_64 GNU/Linux).

I managed to solve it by creating a hybrid ‘’ file (path: /psychopy/experiment/, blending with code from Psychopy2021.1.4 (lines 326-429 in attached file).

I guess this should be fixed more appropriately by the code maintainers, but as far as I can tell, this solution seems to work.




Thanks for this. It worked for me on Windows 10 also. Life saver.

Great to know!

I haven’t been able to replicate this using the standalone on a clean Win10 virtual machine.

And most users seem able to save experiments. So, we need to try and work out what’s different for those that can’t. Is it just particular experiments that won’t save? Maybe just experiments from a previous version? Does a blank new experiment save? Can you think of anything else that’s unusual about your system/setup/experiment that I could try and mimic?

Hi Jon,

I have just installed PsychoPy 2022.1.1 in Ubuntu 21.10, created a new experiment with just a mouse component and could not save it.
Replacing the by the one edited by @marco.tettamanti solved the problem for me.

Is there any way I could help?

Best regards,


I’ve been trying to replicate this issue on my Ubuntu 21.10 dev machine unsuccessfully. Files appear to load/save just fine. Since you are not using stand alone, it might be an issue with your XML library. Try updating the package defusedxml and see if that fixes it.

  • mdc
1 Like

Dear mdc,
thank you, updating with:
pip3 install -U defusedxml
solved the problem with saving experiments on my computer.

1 Like

Thanks @mdc!
That worked in my installation as well.
I’ve just updated my how-to-install-psychopy-on-ubuntu-21-10 citing your solution :wink:
Best regards,

I am having the same issue using a new Standalone install (v2022 1.4) on MacOS 12.4. Can’t save even a blank new experiment.
= = = = =
Traceback (most recent call last):
File “/Applications/”, line 744, in fileSave
File “/Applications/”, line 788, in fileSaveAs
File “/Applications/”, line 747, in fileSave
File “/Applications/”, line 376, in saveToXML
File “/Applications/”, line 361, in _xml
File “/Applications/”, line 237, in append
File “/Applications/”, line 259, in _assert_is_element
TypeError: expected an Element, not Element

I just solved the problem by resetting my preferences to the default settings. Don’t know what my bad preference was (save path? something else??) but anyway it saves now.

Good to know, thanks Jon. I don’t know why that would ever cause a problem with reading the xml, but glad it fixed your issue :slight_smile: