Skip to content

Building: Linux

Vhou edited this page May 20, 2024 · 4 revisions

Building the gag calculator on Linux has a couple quirks that will be addressed in this page.

Pip

On Linux, many installations of Python 3 may not automatically come with pip, and you must install it from your distribution's repositories. Generally, this package will be called python3-pip, but it is best to consult the documentation for your distribution to ensure this is correct.

On a Debian-based distribution, you would be able to install pip by using the command sudo apt-get python3-pip.

Tkinter

Tkinter does not come standard on many Python 3 installations on Linux, and you must install it from your distribution's repositories just like pip. Below is how to install tkinter on several different distributions:

sudo apt-get python3-tk # Debian based distributions
sudo dnf install python3-tkinter # Fedora based distributions
sudo yum install python3-tkinter # RHEL based distributions
sudo pacman -Syu tk # Arch based distributions
sudo zypper in python-tk # openSUSE based distributions
sudo xbps-install python3-tkinter # Void based distributions

Other distributions will need to consult their wikis for instructions on tkinter installation.

Virtual Environments

Some distributions of Linux will require users to create a virtual environment to install libraries through pip without the use of sudo. This is slightly complicated by python3-venv not coming standard in many Python 3 installations, but you can generally install it from your repositories similarly to pip and tkinter: sudo apt-get python3-venv.

When creating your virtual environment for the calculator, you will want to ensure you include system packages. This will ensure tkinter will be included in the environment. This can be done with python3 -m venv .venv --system-site-packages. Once your virtual environment is created, you can activate it with the source command. For example, with a venv named .venv, you would activate the environment with source .venv/bin/activate. In your terminal, you should see a (.venv) in front of the next line of your terminal.

Once your virtual environment is set up, you are able to install any necessary requirements and build the calculator as one normally would.

Clone this wiki locally