| Reference | Downloads | Github

How to install PsychoPy on Ubuntu 21.10

Hi everyone,

I’ve found some time to play with the installation of PsychoPy in Ubuntu 21.10 and, as it went well, I thought someone else could need this. Hopefully, this set of instructions will also work with Ubuntu 22.04, the upcoming LTS version.

It worked in a clean install of Ubuntu 21.10 and PsychoPy 2021.2.3.

First, install outdated psychopy from Ubuntu’s repository

sudo apt install psychopy

Install pip3

sudo apt install pip3

Now, install the packages needed to compile wxPython

sudo apt install python3-pip make gcc libgtk-3-dev libgstreamer-gl1.0-0 freeglut3 freeglut3-dev python3-gst-1.0 libglib2.0-dev ubuntu-restricted-extras libgstreamer-plugins-base1.0-dev

To compile/build your wxPython, “ask” pip3 to force reinstall. Otherwise, it is going to use the xwPython version from Ubuntu’s repository (which won’t work - at least, not for me). This is going to take a while, so press enter and go have some coffee :wink:

pip3 install -v --user -- force-reinstall wxPython

Install Psychtoolbox bindings

sudo apt install libusb-1.0-0-dev portaudio19-dev libasound2-dev

Update psychopy using pip3

pip3 install -U psychopy

Raise the priority of the experiment process

sudo groupadd --force psychtoolbox
sudo usermod -a -G psychtoolbox $USER

Create a 99-psychopylimits.conf file using gedit:

sudo gedit /etc/security/limits.d/99-psychopylimits.conf

Paste in the following text to that file and save it:

@psychtoolbox   -  nice       -20
@psychtoolbox   -  rtprio     50
@psychtoolbox   -  memlock    unlimited

Finally, to avoid Builder to crash when you insert a $ into a textbox, edit the file ([python-package-directory]/psychopy/app/builder/dialogs/
Open the file using gedit and find where updateCodeFont is defined. You just have to comment one line and add another, as indicated below:

    def updateCodeFont(self, valType):
        """Style input box according to code wanted"""
        if not hasattr(self, "SetFont"):
            # Skip if font not applicable to object type
        if self.GetName() == "name":
            # Name is never code
            valType = "str"
        if valType == "code" or hasattr(self, "dollarLbl"):
            # Set font
            # self.SetFont(self.GetTopLevelParent().app._codeFont.Bold()) # Comment this line
            self.SetFont(self.GetTopLevelParent().app._mainFont) # Add this line

Now, you are good to go :wink:
Have fun using Builder in Ubuntu 21.10!