Perhaps I should start by saying that I would not recommend setting up a computer to run experiments in a non-LTS release of Ubuntu, since you get less time of support and need to upgrade it more often (which may break things that are working). Nevertheless, I like to have the most recent version of the OS installed in my notebook, which I frequently use to create and test experiments.
So, if that is also your case, let me show you how to install PsychoPy 2022.2.5 on Ubuntu 22.10.
- If you are looking for an LTS installation, please follow this instructions.
Here, I’ll show how to compile Python 3.8 on Ubuntu 22.10, so that you can use the most up-to-date Ubuntu and still be able to work with PsychoPy.
“Wouldn’t it be easier to use the deadsnakes PPA?”
In fact it would but, as it turns out, we can’t. The PPA is provided for LTS versions of Ubuntu only.
“But, then, couldn’t you just use conda?”
Yes. But what is the fun in it
Kidding apart, I prefer using
virtualenv to manage virtual environments.
So, keep in mind that there is, at least, one alternative to what I’m describing here.
sudo apt update
sudo apt upgrade
sudo apt install swig libpulse-dev libasound2-dev libgtk-3-dev git libwebkit2gtk-4.0-dev libxcb-xinerama0 libegl1-mesa virtualenv wget checkinstall build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
wget checkinstall build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev are needed to download and compile Python 3.8
virtualenv will be needed to create the virtual environment
swig, libpulse-dev and libasound2-dev are needed to install pocketsphinx libgtk-3-dev and libwebkit2gtk-4.0-dev are needed to build wxPython
git is required to save .psyexp file using Builder
libxcb-xinerama0 libegl1-mesa are required to solve an error that prevents Builder from running experiments
Download Python 3.8
Extract the compressed file you’ve downloaded:
sudo tar xzf Python-3.8.16.tgz
Enter the folder you’ve just extracted:
The compilation of Python 3.8 will take two steps only. First, we make sure everything we need is there (
configure) and then we send the files to where they belong (
make install). If you really need to know more about this process I recommend going here.
altinstall instead of install so that the system’s Python installation remains untouched.
sudo make altinstall
To check if everything worked, type:
If it shows “Python 3.8.16” you are good to go.
Let’s create a virtual environment called
psychopy-py38 inside of a folder called
virtualenv --python /usr/local/bin/python3.8 ~/Environments/psychopy-py38
Activate the virtual environment so you can install and configure PsychoPy inside it
First, we need to update deprecated
setuptools, and install
pip install pip setuptools -U
pip install attrdict
Now, lets install PsychoPy 2022.2.5.
During this step, xwPython will be compiled. It takes around 30 minutes - go for a walk
pip install psychopy==2022.2.5
Now you should be able to run PsychoPy.
psychopy --builder &
When you run it for the first time, a popup will tell you that
psychtoolbox needs further configuration. The same steps are described here in case you miss it and want to find them again.
It is also recommended that you go to Properties → Audio and change “Audio library” to “ptb” (i.e. to use psychtoolbox).
Login to pavlovia from Builder is not working. It’s not a new issue, actually - there’s a thread on this problem here. Therefore, I’ve been using gitg to sync my projects with gitlab / pavlovia. If you want to know more about it, leave a comment here.
Builder still crashes when typing a dollar sign into a text component. It is an old bug that came back (it’s a tough bug…). To get rid of it, follow this instructions.
The next time you need PsychoPy, just open the terminal and type
psychopy --builder &
Just a reminder: you must leave the terminal open, otherwise you will shutdown PsychoPy Builder with the terminal.
I hope it helps