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/builder.py”, line 772, in fileSaveAs
self.fileSave(event=None, filename=newPath)
File “/home/jay/.local/lib/python3.9/site-packages/psychopy/app/builder/builder.py”, line 731, in fileSave
filename = self.exp.saveToXML(filename)
File “/home/jay/.local/lib/python3.9/site-packages/psychopy/experiment/_experiment.py”, line 329, in saveToXML
self.xmlRoot = self.xml
File “/home/jay/.local/lib/python3.9/site-packages/psychopy/experiment/_experiment.py”, line 314, in xml
experimentNode.append(settingsNode)
File “/usr/lib/python3.9/xml/etree/ElementTree.py”, line 244, in append
self._assert_is_element(subelement)
File “/usr/lib/python3.9/xml/etree/ElementTree.py”, line 266, in _assert_is_element
raise TypeError(‘expected an Element, not %s’ % type(e).name)
TypeError: expected an Element, not Element
edit
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”"
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”
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.
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.
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 ‘_experiment.py’ file (path: /psychopy/experiment/_experiment.py), 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.
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?
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 _experiment.py by the one edited by @marco.tettamanti solved the problem for me.
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.
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/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/app/builder/builder.py”, line 744, in fileSave
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/app/builder/builder.py”, line 788, in fileSaveAs
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/app/builder/builder.py”, line 747, in fileSave
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/experiment/_experiment.py”, line 376, in saveToXML
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/experiment/_experiment.py”, line 361, in _xml
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/xml/etree/ElementTree.py”, line 237, in append
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/xml/etree/ElementTree.py”, 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.