Develop or Run Python scripts
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 python -m ensurepip --default-pip 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
It’s recommended to avoid installing Python using Homebrew, as this will break kde-builder and potentially any other Python-based software shipped on the system.
Article contributed by Nate Graham under the CC-BY-4.0 license.