psychopy.org | Reference | Downloads | Github

Converting code from PsychoPy2 to PsychoPy3

Hello, I posted previously about trying to run an experiment that was programmed for PsychoPy2 to PsychoPy3, so trying to convert the code by troubleshooting any errors that come up when trying to run it. I am having trouble solving the latest error which is this:

File “…/…/lib/lavatask/base.py”, line 1821, in load
self.data = self._readResource(self.getResourceLocation())
File “…/…/lib/lavatask/base.py”, line 1862, in _readResource
file = codecs.open(self.getResourceLocation(), encoding=None)
File “codecs.pyc”, line 895, in open
FileNotFoundError: [Errno 2] No such file or directory: ‘demo.txt’

Experiment ended.

I understand there were some differences in codecs introduced between PsychoPy2 and 3, so I assume it probably has something to do with that, but I can’t figure out what. I can’t find the “codecs.pyc” file it refers to. Is this created by the code, and if so, maybe there is an error with that?

Any help would be greatly appreciated! Thank you,

Saashi

Those things are all red herrings. Your actual problem is simply this:

FileNotFoundError: [Errno 2] No such file or directory: ‘demo.txt’

You need to make the specified name and location of that file match its actual name and location.

Ok thank you! I did wonder that at first, but I can’t figure out where the demo.txt file is supposed to be. I located the file and tried moving it to a few different locations, but I got the same error. Do you know how I can find out what location it is supposed to be in?
Thanks so much!

No, because it is presumably your file. What do you use it for? Where is it referred to in your code?

Somewhere in your code will be a reference to that file, and its path in your code should match the actual path to the file in the file system.

Thanks so much, I managed to figure it out. Appreciate the help!