Skip to content

Instantly share code, notes, and snippets.

@chrplr
Last active March 27, 2023 10:35
Show Gist options
  • Save chrplr/5e059a766b2984f12a8c2edc0d7dfdbf to your computer and use it in GitHub Desktop.
Save chrplr/5e059a766b2984f12a8c2edc0d7dfdbf to your computer and use it in GitHub Desktop.
installing expyriment in a python virtual environment (Ubuntu 22.04)

expyriment is a great Python library to program psychology experiments.

However pip install expyriment fails with many versions of Python because it tries to recompile pygame

Here we show how to use pyenv to create an environement with Python 3.7.6 in which "pip install expyriment" should work.

Installation

sudo apt install -y python3-pip python-is-python3 python3.10-venv
sudo apt install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl


curl https://pyenv.run | bash

cat >> .bashrc <<'EOF'
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
EOF


source .bashrc


pyenv install 3.7.6
pyenv virtualenv 3.7.6 expyriment

pyenv activate expyriment
pip install expyriment

Running

pyenv activate expyriment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment