Jump to content

KDE Linux/Develop or run Python scripts

From KDE Community Wiki

KDE Linux includes Python, but without any provision for installing additional system-level modules. Many Python programs require the use of modules that aren't pre-installed, so how do you resolve this situation?

The solution is to create a virtual environment, within which you can install whatever dependencies you need:

# Create a new virtual environment in the current directory named "venv"
python -m venv venv

# Activate the "venv" virtual environment
source venv/bin/activate

# Install what you need
pip install [whatever Python modules you need]

# run or develop the tool

# Exit the virtual environment
deactivate

# Optional: delete the "venv" virtual environment if you don't need it anymore
rm -r venv


Note

It's recommended to avoid installing Python using Homebrew, as this will break kde-builder.