-
-
Notifications
You must be signed in to change notification settings - Fork 179
Not able to run a tkinter program #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report. Can confirm this fails on the latest 20221107 distributions. The x86_64-unknown-linux-gnu distribution fails for me on the
This program works with other Python builds on my system. So something is amiss. The There's possibly an upstream bug or two to report in here somewhere. But I don't know what until root cause is understood. |
Here's an excerpt from libxcb's configure:
I have no clue how to interpret any of it though. (I wish all configure scripts gave you concise reports of important metadata like this!) |
And from
|
OK. We compile tk with However, that code in tk ( I think the problem here is we build tcl/tk with support for threads? Is this somehow different from how the entire world builds tcl/tk? Note that I enabled threads in commit 169bdad. But sadly didn't leave any context. (Very uncharacteristic of me!) Commits around it were part of enabling tcl/tk to build on macOS. I wonder if I enabled threads for a reason or just saw they weren't enabled and figured enabling threads was a good idea? |
Hmmm. |
To add on to the debugging - I cannot reproduce when using xvfb in Docker or otherwise |
Could it perhaps be related to the change mentioned here? #95 (comment) |
After a git bisect testing against OP code, I found that this commit is the first bad commit. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Just confirming this is still reproducible after upgrading tcl/tk (#495)
|
Also met the same issue for this simple program (ubuntu 24.0.1 LTS, amd64): import tkinter as tk
def show_window(message):
"""Displays a simple tkinter window with a message."""
root = tk.Tk()
root.withdraw() # Hide the root window initially
window = tk.Toplevel(root)
window.title("Simple Window")
label = tk.Label(window, text=message, padx=20, pady=10)
label.pack()
ok_button = tk.Button(window, text="OK", command=window.destroy)
ok_button.pack()
window.focus_set() # Request focus for the newly opened window
window.grab_set() # Make it modal
root.wait_window(window)
root.destroy()
# window.destroy() # Destroy Toplevel does not actually exit the program.
if __name__ == "__main__":
message_to_show = "This is a simple window!"
show_window(message_to_show) output:
|
Also encountering this, using Arch (btw), but it is working with python 3.8 and 3.13 (none of which i can use in my project)
import tkinter
def main():
root = tkinter.Tk()
button = tkinter.Button(root, text="Click Me")
button.pack(padx=20, pady=20)
root.mainloop()
if __name__ == "__main__":
main()
|
See if For 3.8 I get this traceback
later versions fail with:
|
@rezzubs Ah! Aha, No tcl error (which i've gotten before and worked around using Perhaps i had a version of py 3.8 that was working, but after uninstalling and letting uv grab the latest 3.8 release it breaks. So basically only my system python & older (?) releases of python-build-standalone are working? :-( EDIT: I saw that EDIT 2: Can confirm that So two versions from the same release are inconsistent, 3.10.2 works whereas 3.8.13 from same release does not. I am very confused! |
I encountered a similar issue with Traceback (most recent call last):
File "test.py", line 12, in <module>
main()
File "test.py", line 5, in main
root = tkinter.Tk()
File "/var/home/rezzubs/.local/share/uv/python/cpython-3.8.20-linux-x86_64-gnu/lib/python3.8/tkinter/__init__.py", line 2270, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
/tools/deps/lib/tcl8.6 /var/home/rezzubs/dev/tkinter-test/.venv/lib/tcl8.6 /var/home/rezzubs/dev/tkinter-test/lib/tcl8.6 /var/home/rezzubs/dev/tkinter-test/.venv/library /var/home/rezzubs/dev/tkinter-test/library /var/home/rezzubs/dev/tkinter-test/tcl8.6.12/library /var/home/rezzubs/dev/tcl8.6.12/library
This probably means that Tcl wasn't installed properly. This issue can be resolved by setting the However, if the error message is: [xcb] Unknown sequence number while appending request
[xcb] You called XInitThreads, this is not your fault
[xcb] Aborting, sorry about that.
python3: xcb_io.c:157: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed. I have not yet found a solution for this particular error. |
Since managing Python with uv doesn't work when using tkinter, I decided to manage the Python versions with pyenv and that works quite well.I |
@Mike710Shine interestingly i tried this on my laptop and got the same error, but now when i try on my desktop it works. I must've done something wrong. Are you still able to manage dependencies with uv or you completely went with pyenv? |
@linde12 i manage my dependencies with uv but my python installations with chocolatey on windows and on linux with pyenv. First i install pyenv set the string for the fish shell in the config and then i do the rest with uv and it works. I had this tkinter problem only on the Linux Systems |
I know that pyenv build every python direct from source when i'm right. Maybe it's a good solution that uv has an flag to avoid the installation from the builded source form astral an build it on it's own like pyenv. Maybe this not ends in an not runable tkinter project because i love uv but that i can't run tkinter project when uv manage the python versions only when i use the newest one it is very uncool. |
This probably isn't very useful but the error seems to come from here last commit on that file is precisely clarifying the error message we're seeing mirror/libX11@da97120 The maintainers of python-build-standalone have already acknowledged the bug (#146 (comment)) so it's down to someone to find out what's wrong about https://github.com/astral-sh/python-build-standalone/blob/main/cpython-unix/build-libX11.sh, or libX11 itself, or Tcl/Tk, or CPython... probably some very deep debugging required, a bit of luck, or both. |
The bug almost certainly reduces to loading multiple versions of a library into a binary or there being a mismatch between the build and run time versions. |
Let's keep conversation here focused on the specific bug here rather than uv Python installation behaviors / pyenv / etc. please. |
That commit was included in the latest release, or am i missing something? Because the error still happens with when i install 3.12.9 with uv.
~ via 🐍 v3.13.2
❯ uv python install --verbose 3.12.9
DEBUG uv 0.6.4
DEBUG Acquired lock for `.local/share/uv/python`
DEBUG No installation found for request `Python 3.12.9`
DEBUG Found download `cpython-3.12.9-linux-x86_64-gnu` for request `Python 3.12.9`
DEBUG Using request timeout of 30s
Downloading cpython-3.12.9-linux-x86_64-gnu (20.3MiB)
DEBUG Downloading https://github.com/astral-sh/python-build-standalone/releases/download/20250212/cpython-3.12.9%2B20250212-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz to temporary location: /home/linde/.local/share/uv/python/.temp/.tmpGoaoXR
DEBUG Extracting cpython-3.12.9%2B20250212-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
Downloaded cpython-3.12.9-linux-x86_64-gnu
DEBUG Moving /home/linde/.local/share/uv/python/.temp/.tmpGoaoXR/python to .local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu
DEBUG Skipping installation of Python executables, use `--preview` to enable.
Installed Python 3.12.9 in 4.48s
+ cpython-3.12.9-linux-x86_64-gnu
DEBUG Released lock at `/home/linde/.local/share/uv/python/.lock`
~ via 🐍 v3.13.2 took 4s
❯ uv run -p 3.12.9 --python-preference only-managed test.py
[xcb] Unknown sequence number while appending request
[xcb] You called XInitThreads, this is not your fault
[xcb] Aborting, sorry about that.
python3.12: xcb_io.c:157: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed. |
No, I don't think that commit has been merged. It's on an open branch. |
Ah, then it makes sense. Thanks! |
Someone commented that this was not a problem on MS-Windows.
But if I specify the python version installed from https://www.python.org/downloads/
The application is a basic TKinter app. https://github.com/rnwolf/my_tkinter_app |
I am using the bazel/rules_python to compile our python code.
according to the configuration, we are using the
cpython-3.9.13+20220802-x86_64-unknown-linux-gnu-install_only.tar.gz as our python interpreter.
But as we are using the Tkinter, there is a segment fault during the runtime.
the code
the stack trace
according to other tickets, seems the python interpreter is already linked to the Tkinter.
Update
I was trying to use the debug version to know what happened in the core dump. but it is very strange that I am able to run this with python3.9d. it is very weird.
The text was updated successfully, but these errors were encountered: