pyapp icon indicating copy to clipboard operation
pyapp copied to clipboard

Tcl error using Tk

Open jplumail opened this issue 1 year ago • 3 comments

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

jplumail avatar May 22 '24 15:05 jplumail

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

ofek avatar May 22 '24 16:05 ofek

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 avatar May 23 '24 07:05 jplumail

After searching a bit, I found this https://github.com/indygreg/python-build-standalone/issues/146 No update since November 2022...

jplumail avatar May 23 '24 08:05 jplumail