/psychopy_linux_installer

Installing PsychoPy on Linux can be challenging, so I've created an installer to make the process easier and more streamlined.

Primary LanguageShellGNU General Public License v3.0GPL-3.0

PsychoPy Installation Script for Linux

This script facilitates the installation of PsychoPy on various Linux distributions, including:

  • Ubuntu 24.04, 22.04, 20.04, (18.04)
  • Pop!_OS 22.04
  • Debian 12, 11
  • Fedora 40, 39
  • Rocky Linux 9
  • CentOS 9

Additional distributions may be working.

Note: Ubuntu-18.04 fails to install PyQt6. You can still use Ubuntu-18 with PsychoPy versions =< 2023.2.3. Earlier versions use PyQt5.

Important Information

  • PsychoPy is compatible with Python versions 3.8, 3.9, and 3.10.
  • The specified/default(3.8.19) Python version is installed as altinstall if not present.
  • A directory is created in the specified directory (default: $HOME): {install_dir}/psychopy_${PSYCHOPY_VERSION}_py_${PYTHON_VERSION}.
  • The script first attempts to download a pre-packaged Python .tar.gz file from Nextcloud. If a suitable version isn't found, it will download from python.org and build it from source.
  • For wxPython, the script tries to download from their official site. If this fails, it falls back to Nextcloud or, if necessary, builds wxPython from source. If latest wxpython version fails building, it will fallback to version 4.1.1 if no --wxpython-version is set. (fixes fedora-40)
  • If the downloads fail building Python and wxPython may take 1-2 hours.
  • The script provides minimal output by default. Use the --verbose option for detailed logging.

Usage

(Optional) Update and upgrade packages; change apt-get to your package manager.

sudo apt-get update
sudo apt-get upgrade -y

Install Git

sudo apt-get install git -y

Clone the repository and allow execution:

git clone https://github.com/wieluk/psychopy_linux_installer.git
cd psychopy_linux_installer
chmod +x psychopy_linux_installer

Execute script; see options below for more information.

./psychopy_linux_installer

I would recommend using default values if you do not need specific versions.

Options

Option Description
--python-version=
VERSION
Specify the Python Version to install (default: 3.8.19). Only versions 3.8.x, 3.9.x, or 3.10.x are allowed.
--psychopy-version=
VERSION
Specify the PsychoPy Version to install (default: 2024.1.1).
--wxpython-version=
VERSION
Specify the wxPython Version to install (default: latest).
--install-dir=DIR Specify the installation directory (default: $HOME); use absolute paths without a trailing /. Do not use ~/; use /home/{user} instead.
--no-versioned-install-dir Installs directly into the specified install-dir without creating a versioned subdirectory. Requires --install-dir.
--additional-packages=
PACKAGES
Specify additional pip packages to install. Format: package1==version,package2. No extra packages are installed if not set.
--build=
[python|wxpython|both]
Build Python and/or wxPython from source instead of downloading wheel/binaries. Use both if something does not work. Note: This process might take 1-2 hours.
--sudo-mode=
[ask|auto|error|continue|force]
Control sudo usage. ask: confirm, auto: auto-confirm, error: exit if sudo needed, continue: continue without sudo, force: use sudo directly.
-f, --force Force overwrite of the existing installation directory.
-v, --verbose Enable verbose output.
--disable-shortcut Disable desktop shortcut creation.
--disable-path Disable adding psychopy to system path.
-h, --help Show help message.

Note:

  • The default version for --psychopy-version is set to 2024.1.4 Because new releases for Linux often introduce bugs that require manual fixes. For example 2024.2.1 has problems with opening the GUI when not installing a earlier version first.
  • --psychopy-version, --wxpython-version and can take a actual pypi version,latest or git as argument. Git versions are not recommended because they can be unstable.

Examples

  • ./psychopy_linux_installer (all default)
  • ./psychopy_linux_installer --psychopy-version=2024.1.4 --install-dir=/home/user1 --additional-packages=psychopy_bids,seedir,psychopy-crs==0.0.2 --sudo-mode=auto --build=python -v -f

Script Details

The script performs the following steps:

  • Detects the package manager (supports apt, yum, dnf, and pacman).
  • Installs necessary dependencies.
  • Creates a directory in the specified location for PsychoPy.
  • Checks if the specified Python version exists if necessary downloads and install it as altinstall.
  • Creates and activates a virtual environment for PsychoPy.
  • Installs/builds wxPython.
  • Upgrades pip and some pip packages.
  • Install specified PsychoPy version.
  • Adds the current user to a psychopy group and sets security limits.
  • Creates a symbolic link to the PsychoPy executable in .bin.
  • Creates a desktop shortcut.

Post-Installation

After installation, desktop icons for PsychoPy will be created automatically, and the application will be added to your system's PATH as:

psychopy_${PSYCHOPY_VERSION}_py_${PYTHON_VERSION}

Refreshing your system's PATH is necessary.

You can also launch PsychoPy directly using the absolute path:

${PSYCHOPY_DIR}/bin/psychopy

Note: All commands, along with the installed versions and set paths, as well as the command to refresh your system's PATH, will be displayed at the end of the script.

To-Do

  • Refactor testscripts.
  • Conduct tests on a physical machine.
  • Test with connected hardware components.
  • Test on Pacman-based distributions.

Links

Automated Installation, Test and build Results

View the latest installation test results

View the build results

Builds

wxPython on Nextcloud

Python on Nextcloud