So you’re trying to install Pyfa on Ubuntu 20.04 (or some derivative like Pop!_OS) and are likely running into problems at some point along the way because everything does not just magically work out of the box. I’ll explain how to do this and I’ll explain why these deviations are necessary so you understand this is not just some random magic that happened to work once.
Install System Dependencies
First, you need git installed so you can clone the Pyfa repo. You will also need the GTK+ 3 and Python 3 development libraries in order to build wxPython, which is required for Pyfa to work.
Since I do a lot of development work in Python, I don’t want to crap up my system’s Python libraries, so I’m going to do all of this inside of a Python virtual environment which keeps all the things related to Pyfa separated from the Python packages used by my system and other applications that rely on Python; for this reason we need virtualenv too.
sudo apt install git virtualenv libgtk-3-dev python3-dev
Clone the Pyfa Code
Now, if you haven’t already, you need to clone the Pyfa git repo. This essentially copies all the stuff from https://github.com/pyfa-org/Pyfa to your local machine. I’m running this command from my home directory, /home/dephekt, but you can do it from anywhere you want. The files will end up in /home/dephekt/Pyfa:
git clone https://github.com/pyfa-org/Pyfa
Create a Python Virtual Environment
Now change into the new Pyfa directory:
Then create a Python environment for Pyfa:
This will create a directory called “.env” in /home/dephekt/Pyfa/.env where all the Python dependencies used by Pyfa will be installed later. Now, activate that environment in your shell:
From here on out, Python commands you run like “pip” will do their work in the context of this fresh Python environment we created.
Install and Build Python Dependencies
Now, we can start installing the Python dependencies. First, we need one that isn’t included in Pyfa’s requirements.txt file, which is pathlib2:
pip install pathlib2
You need this because the build script for wxPython requires it to be available. If you don’t install it, the next step will quickly fail because the pathlib2 module isn’t present.
Now, you can install the rest of the dependencies:
pip install -r requirements.txt
Now, feel free to grab a drink while your computer builds wxPython. It will take a while, depending on the speed of your CPU and how many cores you have to throw at GCC. When it’s done, you should be all set.
At this point, you should be able to run ./pyfa.py and Pyfa should run.
Running Pyfa Moving Forward
Keep in mind, you need to use the Python binary in the Pyfa virtual environment you created when running Pyfa. If you close out of this current terminal and open it back up and go back to Pyfa and run ./pyfa.py, it’s not going to work. You need to run it one of two ways (these are assuming you are already in $HOME/Pyfa):
source .env/bin/activate ./pyfa.py
Or you can directly execute the Python binary inside the environment and tell it to run pyfa.py:
Bash and Zsh Aliases
The latter example is the easiest way to run it as a one-liner which is especially useful if you want to make a bash or zsh alias to run Pyfa:
echo $'\n'"alias pyfa=\"$HOME/\"'Pyfa/.env/bin/python $HOME/Pyfa/pyfa.py >/dev/null 2>&1 &'" >> $HOME/.bash_aliases echo $'\n'"alias pyfaup=\"cd \\\"$HOME/Pyfa\\\" && git pull\"" >> $HOME/.bash_aliases source "$HOME/.bashrc"
If you do this, you can just run “pyfa” from a shell anywhere and it should execute Pyfa using your virtual environment’s Python installation. It will redirect stderr and stdout to /dev/null and run the command in the background, so you can close your terminal after and Pyfa will stay open and you won’t see terminal output from Pyfa anymore.
Running “pyfaup” will change into your Pyfa directory and trigger a “git pull” which pulls down the latest changes from the developers master branch. You only need to run the “source” command once here, in order to apply these changes to your currently open terminal. If you close the terminal and reopen it, it should automatically “source” your .bash_aliases or .zshrc.
If you use zsh instead of bash, like I do, just change the $HOME/.bash_aliases part to $HOME/.zshrc and you should be all set.
Post here and let me know if this helped you. Alternatively, post here to tell me I’m an idiot and this didn’t help you at all. If you have questions, feel free to ask and I’ll do my best to help.
- Updated the bash/zsh alias for pyfa to execute Pyfa in the background and redirect output to /dev/null so you can close your terminal after starting Pyfa.