Run the following command in your terminal to install all required libraries:
pip install psutil
pip install pygame
pip install plyerAlternatively, install all dependencies in one command:
pip install psutil pygame plyerEnsure you're using Python 3.6 or later. You can check your Python version with:
python --versionPyInstaller is the primary tool used for creating executables. Install it with:
pip install pyinstallerAdditionally, win10toast may be required for Windows notifications. Install it with:
pip install win10toastEnsure your folder looks like this:
/your_project_folder
├── battery_monitor.py
├── warning.wav
├── battery_icon.ico
Run the following command to generate the .exe file:
pyinstaller --onefile --windowed --add-data "warning.wav;." --icon=battery_icon.ico --hidden-import=plyer.platforms.win.notification --hidden-import=win10toast battery_monitor.pyAfter PyInstaller completes, you'll find the .exe file in the dist folder:
/your_project_folder
├── dist/
│ └── battery_monitor.exe
├── build/
├── battery_monitor.spec
If you're on Linux or macOS, adjust the --add-data syntax to use : instead of ;:
--add-data "warning.wav:."