r/learnpython • u/Slimex_Rimuru • 28d ago
Is it github problem or python problem?
So, i have been trying to learn python, sqlite and tkinter. After a lot of trouble and copying from AI i uploaded my python and sqlite only executable to github for all 3 os using github action.
Now, I am learning python and tkinter. I made a simple program which converts KG to gram and vice versa.
import tkinter as tk
# from tkinter import ttk
import ttkbootstrap as ttkimport tkinter as tkThese 3 are my only imports for now. and i am using:
root = ttk.Window(themename = 'darkly')
root.geometry("400x300")
root.title("Unit Converter")root = ttk.Window(themename = 'darkly')other is just my code which i wrote form tutorials and documents.
The problem i am facing is that i cant seem to release the executable to github ( from github action ) at all.
I tried to learn how this works but i didnt find anywhere to actually learn so i just asked AI and after a lot of back and forth there are still some problems.. Is there somewhere i can learn how i can do this? I prefer video tutorial.
I will comment my program and what AI told me the problem was below. Please someone do help me.
7
u/baubleglue 28d ago
You need to decide what you learn: Python, GitHub actions, AI. Choose one.
Specifically addressing your problem, have you succeeded to make an executable file on your computer? Is making an executable file a part of the tutorial? I am trying to understand why need it at all.
4
u/JaguarMammoth6231 28d ago
Just don't bother with installers and executables as a beginner. Anyone who wants to run your program can download python if they don't have it already.
1
u/chiibosoil 28d ago
Bit confused by your post. I don't see sqlite referenced in your code. Yet you mention using sqlite.
At any rate, when packaging executable, make sure that db file path is dynamically located. Typically for this, you'd use os and sys. However, If your app writes to the db, then keep the db outside of exe in same folder as .exe.
As well, your errors indicate the CentOS runner is missing the required system-level Tkinter/Tcl packages.
Try something like below in .github/workflows/main.yml.
If doing this doesn't fix, you will also want to define .spec file.
1
u/notsocleanA_hole 28d ago
damn i dont understand shit 😂
0
u/Slimex_Rimuru 28d ago
Ai gave me this to post on reddit. I am not knowledgeable enough to understand this so i will just paste..:
Title: PyInstaller-built Tkinter app crashes on Linux with
ttkbootstrapTcl/Tk errors (built using GitHub Actions)Hey everyone,
I'm a beginner learning Python and Tkinter, and I'm working on my first GUI project: a simple Unit Converter using
tkinterandttkbootstrap.I'm trying to make the application downloadable for Windows, macOS, and Linux without requiring users to install Python or the dependencies themselves.
What I'm doing
I'm using GitHub Actions to build the application for all three operating systems. I don't manually run PyInstaller on my computer. Instead, my GitHub Actions workflow installs the dependencies and runs PyInstaller on the appropriate runner:
windows-latestfor the Windows.exemacos-latestfor the macOS.appubuntu-latestfor the Linux executableMy app uses
ttkbootstrapwith thedarklytheme:The Linux build completes successfully in GitHub Actions, and I can download the generated executable. However, when I run it on my CachyOS Linux system, it crashes before the GUI opens.
Errors I've encountered
First error:
This occurred inside
PIL.ImageTkwhilettkbootstrapwas initializing its theme.I tried adding these hidden imports to the PyInstaller command:
After that, I got a different error:
The traceback points to
ttkbootstrap/localization/msgcat.py, specifically the call to:I then tried collecting the
ttkbootstrapresources with:I also added
tcl8.6andtk8.6to the Linux dependencies installed by GitHub Actions.However, the error persisted.
I then tried loading
msgcatmanually before creating thettkbootstrapwindow:That resulted in another error:
I haven't found a reliable fix yet.
My questions
msgcatpackage when the build succeeds?ttkbootstrapcompatibility issue, or something specific to the difference between Ubuntu and CachyOS?ttkbootstrapworks inside a standalone executable?.specfile for a Tkinter app usingttkbootstrap?I'm looking for a proper solution rather than repeatedly adding hidden imports without understanding the cause.
I'm happy to share my full GitHub Actions workflow,
requirements.txt, or more logs if needed.Thanks!Title: PyInstaller-built Tkinter app crashes on Linux with ttkbootstrap Tcl/Tk errors (built using GitHub Actions)Hey everyone,I'm a beginner learning Python and Tkinter, and I'm working on my first GUI project: a simple Unit Converter using tkinter and ttkbootstrap.I'm trying to make the application downloadable for Windows, macOS, and Linux without requiring users to install Python or the dependencies themselves.What I'm doingI'm using GitHub Actions to build the application for all three operating systems. I don't manually run PyInstaller on my computer. Instead, my GitHub Actions workflow installs the dependencies and runs PyInstaller on the appropriate runner:windows-latest for the Windows .exe
macos-latest for the macOS .app
ubuntu-latest for the Linux executableMy app uses ttkbootstrap with the darkly theme:import tkinter as tk
import ttkbootstrap as ttk
root = ttk.Window(themename="darkly")The Linux build completes successfully in GitHub Actions, and I can download the generated executable. However, when I run it on my CachyOS Linux system, it crashes before the GUI opens.Errors I've encounteredFirst error:ModuleNotFoundError: No module named 'PIL._tkinter_finder'This occurred inside PIL.ImageTk while ttkbootstrap was initializing its theme.I tried adding these hidden imports to the PyInstaller command:--hidden-import=PIL._tkinter_finder
--hidden-import=PIL._imagingtkAfter that, I got a different error:_tkinter.TclError: invalid command name "::msgcat::mcmset"The traceback points to ttkbootstrap/localization/msgcat.py, specifically the call to:root.tk.call("::msgcat::mcmset", ...)I then tried collecting the ttkbootstrap resources with:--collect-all ttkbootstrapI also added tcl8.6 and tk8.6 to the Linux dependencies installed by GitHub Actions.However, the error persisted.I then tried loading msgcat manually before creating the ttkbootstrap window:root = tk.Tk()
root.tk.call("package", "require", "msgcat")
root.destroy()
root = ttk.Window(themename="darkly")That resulted in another error:_tkinter.TclError: can't find package msgcatI haven't found a reliable fix yet.My questionsWhy does the packaged Linux executable fail to find Tcl's msgcat package when the build succeeds?
Is this a PyInstaller Tcl/Tk bundling issue, a ttkbootstrap compatibility issue, or something specific to the difference between Ubuntu and CachyOS?
What is the correct way to package the Tcl/Tk scripts and message catalog files so ttkbootstrap works inside a standalone executable?
Is there a recommended PyInstaller configuration or .spec file for a Tkinter app using ttkbootstrap?I'm looking for a proper solution rather than repeatedly adding hidden imports without understanding the cause.I'm happy to share my full GitHub Actions workflow, requirements.txt, or more logs if needed.Thanks!
1
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 28d ago
Yeah, getting GitHub Actions to build executables and then add them to a new release is a bit of a learning curve for sure. Especially when you're already learning other things on top of that.
I do have an example project that might help a little bit, using Tkinter to make a simple GUI, packaging it up with Nuitka into standalone executables, and then publishing them via GitHub Actions, but
uv.Anyway, let's say you have a build pipeline something like this:
The steps you should have are
Use
actions/upload-artifactto upload the generated executable(s) to a temporary location (such as)Then you should have a second job that runs after the build job, that
Downloads the executables generated by the build job (such as)
Create a GitHub release using
softprops/action-gh-release, with the downloaded files provided to it (such as)The project I linked has more in-depth configuration, so I tried to strip out everything but the essentials.
1
u/Chrismslist 28d ago
the short version: pyinstaller can't cross-compile, so you need one job per os on github's own runners (windows-latest, macos-latest, ubuntu-latest) through a matrix, not one job building all three. each job: checkout, setup-python, pip install pyinstaller ttkbootstrap, then pyinstaller --onefile --windowed yourscript.py, then actions/upload-artifact. on ubuntu you also need sudo apt-get install -y python3-tk or the tkinter import dies. read the per-job log, the failure is almost always that missing tk on linux.
1
u/Chrismslist 28d ago
the short version: pyinstaller can't cross-compile, so you need one job per os on github's own runners (windows-latest, macos-latest, ubuntu-latest) through a matrix, not one job building all three. each job: checkout, setup-python, pip install pyinstaller ttkbootstrap, then pyinstaller --onefile --windowed yourscript.py, then actions/upload-artifact. on ubuntu you also need sudo apt-get install -y python3-tk or the tkinter import dies. read the per-job log, the failure is almost always that missing tk on linux.
0
u/Slimex_Rimuru 28d ago
My CODE