Skip to content
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

Tcl error using Tk #133

Open
jplumail opened this issue May 22, 2024 · 3 comments
Open

Tcl error using Tk #133

jplumail opened this issue May 22, 2024 · 3 comments

Comments

@jplumail
Copy link

I got an error when trying to distribute my Tkinter app:

_tkinter.TclError: Can't find a usable init.tcl in the following directories: 
    /home/plumail/.local/share/pyapp/spfluo-app/7904589091198436804/0.1.12/bin/../lib/tcl8.6 /tools/deps/lib/tcl8.6 /home/plumail/.local/share/pyapp/spfluo-app/7904589091198436804/0.1.12/lib/tcl8.6 /home/plumail/.local/share/pyapp/spfluo-app/7904589091198436804/lib/tcl8.6 /home/plumail/.local/share/pyapp/spfluo-app/7904589091198436804/0.1.12/library /home/plumail/.local/share/pyapp/spfluo-app/7904589091198436804/library /home/plumail/.local/share/pyapp/spfluo-app/7904589091198436804/tcl8.6.12/library /home/plumail/.local/share/pyapp/spfluo-app/tcl8.6.12/library



This probably means that Tcl wasn't installed properly.

Apparently it is a known issue when distributing python: https://gregoryszorc.com/docs/python-build-standalone/main/quirks.html#tcl-tk-support-files

@ofek
Copy link
Owner

ofek commented May 22, 2024

Thanks! If you can tell me your workaround then I can document as a troubleshooting note.

@jplumail
Copy link
Author

jplumail commented May 23, 2024

This is the workaround in the link:

import os
import sys

os.environ["TCL_LIBRARY"] = os.path.join(os.path.dirname(sys.executable), "..", "lib", "tcl8.6")

import turtle

It doesn't work because tcl is not included in the lib folder.
However I found it in the python distribution cached at ~/.cache/pyapp/distributions/_14656550572188801628/python/lib/tcl8.6/.

But when I try this path, I get a new error:

[xcb] Unknown sequence number
while appending request
[xcb] You called XInitThreads, this is not your fault
[xcb] Aborting, sorry about that.
python3: ../../src/xcb_io.c:157: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed.
Abandon (core dumped)

To reproduce

curl https://github.com/ofek/pyapp/releases/latest/download/source.tar.gz -Lo pyapp-source.tar.gz
tar -xzf pyapp-source.tar.gz
mv pyapp-v* pyapp-latest
cd pyapp-latest

PYAPP_PROJECT_NAME=guitk PYAPP_PROJECT_VERSION=0.4.3 PYAPP_EXEC_MODULE=guitk cargo build --release

mv target/release/pyapp ../guitk && cd .. && chmod +x guitk

Then:
TCL_LIBRARY=~/.cache/pyapp/distributions/YOUR_NUMBER/python/lib/tcl8.6/ ./guitk

@jplumail
Copy link
Author

After searching a bit, I found this indygreg/python-build-standalone#146
No update since November 2022...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants