I started this to ask for help, but then I found out more myself, so now I’m mostly putting this here to help anyone else who might try to install PsychoPy on Ubuntu in the future.
Missing gcc/python-3-dev packages
I’m using a fresh install of Ubuntu 20.04, with python v. 3.8.2. I tried to follow the installation instructions for Linux-based systems, which end with:
pip install psychtoolbox
So I set up a virtual environment with venv, ran the previous commands (
pip install psychopyinstalling the appropriate wxPython wheel and building psychtoolbox bindings), then executed the above command from inside it. But then I got errors, saying among other things
unable to execute ‘x86_64-linux-gnu-gcc’: No such file or directory
C compiler or Python headers are not installed on this system. Try to run:
sudo apt-get install gcc python3-dev
I followed the instructions and ran
sudo apt-get install gcc python3-dev (from outside of the virtual environment). I then tried
pip install psychtoolbox (from inside the venv) again, and this time it seemed to work.
Missing Simple Directmedia Layer (SDL) libraries
However, when I tried to start psychopy (
psychopy from within venv), I got “ImportError: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory”. Some duckduckgo:ing lead me to try
sudo apt-get install libsdl2-2.0 (outside of the venv). Now finally when I ran
psychopy (within venv), PsychoPy3 Builder started up.
Missing Qt platform plugin
I created a “hello world” experiment and tried to run it. I however got another error message, ‘Could not load the Qt platform plugin “xcb” in “” even though it was found…’. I looked around, found this thread, ran
sudo apt-get install libxcb-xinerama0 (outside venv), which fixed this issue.
PsychToolBox (PTB) priority error
When running PsychoPy experiments again now, I got “PTB-CRITICAL: In call to PsychSetThreadPriority(): Failed to set new basePriority 2, tweakPriority 1, effective 1 [REALTIME] for thread (nil) provided!”. I searched around a bit and found this fairly obscure solution described by the user Detlef:
(before using this, you might want to read on and see if you can skip the very hefty downloads here)
sudo apt install octave sudo apt install psychtoolbox-3-common sudo apt install octave-psychtoolbox
cding into ‘/usr/share/psychtoolbox-3/’, running
sudo octave --no-gui, then (in the Octave shell)
PsychLinuxConfiguration.m, and answering yes to seemingly relevant questions, above all the ones related to creating a new user group with special privileges (making sure to add not only root, but my own user account to it as well).
I had a look at the “PsychLinuxConfiguration.m” file. It looks like the commands related to user privileges that it actually executes are:
sudo groupadd --force psychtoolbox sudo usermod -a -G psychtoolbox <username> sudo usermod -a -G dialout <username> sudo usermod -a -G lp <username> sudo usermod -a -G video <username>
(replace with your own Ubuntu username, of course)
The script also creates a new file (on my system, and presumably all Ubuntu systems) in the directory “/etc/security/limits.d/”, at least in my case this file was “/etc/security/limits.d/99-psychtoolboxlimits.conf”. The contents are simple, with the relevant lines being:
@psychtoolbox - nice -20 @psychtoolbox - rtprio 50 @psychtoolbox - memlock unlimited
(if /etc/security/limits.d/ doesn’t exist, the matlab script modifies a configuration file at /etc/security/limits.conf, but again, I’m guessing all Ubuntu installations come with the “limits.d” folder)
I think those are the only things that are really needed for dealing with the “Priority()” issue.
In spite of all the above steps, things still don’t work entirely as they should.
Note how the Psychopy icon in the desktop sidebar to the left (fifth icon from the top) is very glitchy and doesn’t look at all the way it should - it’s the same thing if I e. g. alt+tab over to PsychoPy - the icon is broken. The components in PsychoPy’s right sidebar don’t have any images to represent them, instead it’s all text.
Those are a lot of hoops that I had to jump through to make PsychoPy run on a clean Ubuntu installation, and even now it’s glitchy. I had to install a bunch of packages that take up a lot of space, and I’m not sure if I can just uninstall them now without breaking PsychoPy. I’d say that at the moment, at least the most recent versions (I used ‘2020.2.4post1’, as this is what was automatically installed by pip) of PsychoPy don’t seem to really be compatible with Ubuntu. There are also a number of threads filled with frustration about this, e. g. this one or this one.
As noted in the latter thread I linked above, it’s hard to make sure that instructions include all necessary dependencies et c. for all Linux users, and there are limited resources for open source projects. But perhaps the installation instructions could be changed so that they explicitly explain that A) many users have trouble setting up PsychoPy on Linux platforms, and B) it’s strongly recommended that users if possible instead use a Windows/Mac computer with the standalone version, and otherwise they are more or less on their own. This could save a lot of time for everyone involved, I think.