TL;DR: I used pyenv
to install a Python version separate from the system Python. The rest is not significantly different from OP.
Yesterday I successfully(?) installed PP on Ubuntu 22.04, and my method differs a little bit from yours so let me present it. You seem to have experience with installing PP so do let me know if you notice any problems.
The biggest difference is that I didn’t use or touch the system Python. As I mentioned, it’s best not to change that, because it may cause trouble with system packages that expect a particular version. On a machine solely used for PP this may not be an issue, but overall it’s a risk better to avoid. Also, it makes things simpler.
-
Install pyenv; don’t forget the Python build dependencies
-
Install Python 3.8.13 with
pyenv
, designate it as default python for current folder:
mkdir pp-build
cd pp-build
pyenv update
pyenv install 3.8.13
pyenv local 3.8.13 # this creates a file named .python-version
It’s not essential to create a new folder (here pp-build
), the only reason I did so is because I’m changing the local default Python to another version, which creates a file named .python-version
in the current folder. Having it in a new folder means it won’t have effect anywhere else.
I used Python 3.8 because that seems to be the recommended version. Haven’t tried other versions on 22.04 yet.
- Install base dependencies:
sudo apt install ubuntu-restricted-extras curl build-essential
These are essential packages often used not just for PP. (I admit the grouping of dependencies in points 3-5 is somewhat arbitrary.)
- Install PP
sudo apt install swig libpulse-dev libasound2-dev # for pocketsphinx
python -m pip install -U pip setuptools wheel # update basic tools for building and installation
pip install psychopy # should compile at this point
During the process, pip
compiles packages into wheels, which are cached and can be used for later installations. This is handy if one wants to purge this build environment later in order to install PP into a clean one. The wheels won’t need to be rebuilt.
- Install
wxpython
sudo apt install libtiff-dev libjpeg-dev libgtk-3-dev freeglut3 freeglut3-dev \
libwebkit2gtk-4.0-dev libsdl2-dev libsecret-1-dev libnotify-dev \
libgstreamer-plugins-base1.0-dev gettext make libglib2.0-dev
pip install wxpython # should compile
Once wxpython
wheels become available for Ubuntu 22.04, this step will be reduced to downloading and installing that wheel (descibed here).
Some of the above packages have newer versions, e.g. libgtk-4-dev
and libwebkit2gtk-4.1-dev
, that didn’t work well for wxpython
.
-
Install(has wheel, already installed)psychtoolbox
The documentation says it’s necessary to compile psychtoolbox
as well, but this is probably outdated as PTB has manylinux wheels that was already installed as a PP dependency in step 4 without any issues.
- Priority & security limits
See @bastosfh’s original post above.
- Cleanup?
At this point, I’d probably delete the entire Python 3.8.13 installation and reinstall it, then create a virtualenv specifically for PP. As the dependencies are already built, they can be installed again from wheels and won’t need dependencies (needs to be tested).
It might be also OK do remove (most of) the apt
packages that are only required for building.
- Enjoy?
So, I was able to successfully install psychopy
and wxpython
, but I haven’t tested if everything worked well. Opening a window
and visual
stimuli seem to work, but I haven’t tested audio, input, movie etc. yet. Builder and Coder launched, but I’ve never used them so can’t test if everything is OK.
Psychopy may have other dependencies that I didn’t consider, and if those need to be compiled, that’s of course best done before cleaning out the build environment.
- Discussion (feedback is appreciated)
-
I think the list of
apt
packages in OP by @bastosfh could be trimmed a bit. Some of them were already auto installed on Ubuntu either by default or as a dependency of one of the other packages:
gcc libgstreamer-gl1.0-0 libgl1-mesa-dev libglu1-mesa-dev libsm-dev libxtst-dev
. -
Some, I think, used to be required for
psychtoolbox
, but now that it has a wheel, not needed:
libusb-1.0-0-dev portaudio19-dev
. -
Others, I don’t know. The packages compiled without errors, but it’s possible that it would be better to have some of these dependencies?
wxpython
, in particular, skips some missing packages and only issues warnings that don’t appear unless the build fails, which means some functionality may be disabled. I wonder which of these packages I should’ve installed:
python3-pip python3-gst-1.0 python3-testresources python-dev-is-python3 bison autoconf libtool-bin libsndfile1-dev libportmidi-dev liblo-dev nodejs
Pip is one I guess is only needed for the system Python. Other dev packages are probably required by some build process, but their absence didn’t cause any errors. I’m assuming they aren’t required for runtime. -
Full PP functionality likely requires other dependencies, e.g. VLC, FFMPEG that I haven’t bothered to install and test.
-
As you may have noticed, I did not use a virtualenv for the initial build process. The reason for this is that virtualenvs (at least those generated by
pyenv virtualenv
) are missing essential components required to buildwxpython
(e.g.python-config
and header files). This means that the installation of 3.8.13 isn’t pure anymore and any application using that would be affected. However, this is only temporary because once the wheels are built for the dependencies, it’s possible to delete and reinstall this version of Python, and then use a virtualenv. A bit inconvenient, but only requires a few extra steps.