A year or so ago, I posted a whole mess of problems I was having getting current versions of MPF to run on a clean installation of Xubuntu/Lubuntu, and other threads indicated similar issues faced by other folks. The instructions weren't cutting it for me, and it was just one error after another. It didn't matter if I installed using the script from the docs, or manually with pip. None of the suggestions provided by others got things working. Well, I ultimately gave up and I've been running on Windows since, which is less than ideal for running on smaller hardware platforms, as well as productionizing your build, not to mention license costs...
So I finally sat down to try again on all the latest versions of things along with the latest instructions, and... it was still totally nonfunctional... I couldn't even get base MPF to install, much less work. <womp, womp> BUT!! This time I dug in and I got it figured out and working, so I documented my journey and now I'm here to share it with you! I even wiped my test PC and reinstalled a second time following my own instructions, just to be sure it worked in one clean go. I'll be skipping some broad strokes (such as step-by-step details on how to install your OS), but hopefully this will be enough to get others going without all the grief.
Now, I'm not a linux expert, not by a longshot, so maybe this isn't all the most graceful or efficient... heck, maybe it's even painfully obvious to others. As such any feedback on streamlining this would be welcomed! It is my hope, in fact, that someone will dress this up and incorporate it into the MPF setup docs eventually, but if not, at least it's here for posterity.
With no further ado, here it is: a pretty bulletproof approach to getting the latest (pre-0.80) version of MPF working on the current version of Xubuntu on an x86 platform!
-------------------------------
Install Xubuntu 24.04.1 LTS. I just used Balena Etcher to write the ISO to a thumb drive, then booted off of it and installed. Nothing fancy here. Say yes to install any 3rd party software, download updates, and auto login without password. Once your install is done, run the software updater and update any software that needs it.
Install dependencies (the following is one long command). This step is essential for making everything after work properly:
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libjpeg8-dev libxcb-* wget
I can't say for certain that every one of these is needed (I haven't had the patience to try them one by one, far too many combinations), but I can verify that as a group they work. Drop a comment if you can verify that any of these are not actually needed. If you don't intend to run the MPF Monitor application, I believe you can skip the libxcb-* packages (MPF and MC seemed to be running fine without it, but I didn't test this extensively).
Add the deadsnakes ppa. This is how you'll get Python 3.9 installed instead of v3.12 that comes with Xubuntu 24 (which is incompatible with MPF at this time):
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
Install Python 3.9
sudo apt install python3.9 python3.9-venv python3.9-dev
Verify the installation (make sure the '3.9' is in your command or this won't verify the correct installation):
python3.9 --version
If this doesn't work, you need to back up and figure out what went wrong, but you definitely can't proceed until this checks out.
I'm not sure what the current feelings are around using virtual environments or not, but I choose to stick with using a virtual environment because it just makes things work cleanly and it's so easy to recover from setup errors without polluting your whole system. I also usually create it within my game folder so it's easy to reference with any startup scripts you may choose to write, but it can more or less live anywhere you like.
That said, create your venv (SUPER critical to get that '3.9' in here again or you'll build your venv with the wrong version of Python and nothing will work):
python3.9 -m venv /path/to/your/venv
Substitute /path/to/your/venv with your actual desired path. The directory will be created if it doesn't exist and the venv will be created within the final folder specified.
Activate the venv:
source /path/to/your/venv/bin/activate
You'll see the venv name prepended to the command line if this worked.
Verify the venv is a Python 3.9 venv:
python --version
You'll notice I've left out the '3.9' in the command line here. This is intentional. Because the 3.9-created venv is now active, this should report 3.9.x even though you didn't specify it in the command line. If not, time to retrace your steps. You'll probably need to delete your venv and recreate it.
Install MPF/MC/Monitor latest (I do these separately just so it's super clear where the problem came from if you have any problems). Also install uvloop so the game runs buttery smooth:
pip install mpf==0.57.4.dev1
pip install mpf-mc
pip install mpf-monitor
pip install uvloop
Verify your mpf is found and correct:
mpf --version
Now just get your machine files installed, and do a quick test to make sure things are running. Everything should work (assuming your game config is error free).
- Fire up the monitor in one console tab (activate your venv as above then run mpf monitor from your game folder)
- Fire up your game in another tab (activate your venv as above then run mpf both -X from your game folder to start).
If you got this far, you did it! Congrats!!
Other notes:
- In the OS screensaver settings, disable your screensaver and lockscreen.
- In the OS power manager, disable display power management.
- If you want to run your production game with PyPy go here for this and other finalization details (I have tested that the production bundler works, but I have not tested PyPy at this time, so... you may find other missing dependencies here, let us know if you do): https://missionpinball.org/latest/finalization/software/
- If you want to hide your mouse pointer on the display when not in use, install something like unclutter and set it to run as a startup application. (Google "ubuntu mouse unclutter" for more detail.)
- If you will be using git, you can add it to the package list on the initial dependency installation step.
- I suspect this will all be effectively identical for Lubuntu or Ubuntu installations, as well as for different versions than 24.x, but it is untested by me at this time, so YMMV.
- I haven't tested EVERYTHING in my game yet, and I'm certainly not using every feature of MPF, but this procedure got things installed and running. If you find any other prerequisites that need to be installed for other features (e.g. showcreator), please share them here!
Happy MPFing! :)
Kaydee