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
Mac Big Sur Tkinter Black Screen #849
Comments
What version of tkinter? Do you can put a relevant part of pip list? |
The current python distributions (such as 3.9.1) embed tkinter (no longer using a framework version):
Python 3.9.1 (v3.9.1:1e5d33e9b9, Dec 7 2020, 12:10:52)
[Clang 6.0 (clang-600.0.57)] on darwin
>> tkinter.Tcl().eval('info patchlevel')
‘8.6.8'
Location of tkinter modules (with latest Python distributions): /Library/Frameworks/Python.framework/Versions/3.9/lib
The freeze process seems to find the right modules with below setup.py
Herm Fischer
import sys
from cx_Freeze import setup, Executable
import tkinter
from tkinter import ttk
base = None
if sys.platform == "win32":
base = "Win32GUI"
executables = [Executable("SimpleTkApp.py", base=base)]
setup(
name="simple_Tkinter",
version="0.1",
description="Sample cx_Freeze Tkinter script",
executables=executables,
options={
"build_exe" : {
"packages": ["tkinter"],
"include_files": [
('/Library/Frameworks/Python.framework/Versions/3.9/lib/tcl8.6','lib/tcl8.6'),
('/Library/Frameworks/Python.framework/Versions/3.9/lib/tk8.6','lib/tk8.6'),
],
"excludes": ["Tkinter"],
}
}
)
… On Jan 4, 2021, at 5:51 AM, Marcelo Duarte ***@***.***> wrote:
What version of tkinter? Do you can put a relevant part of pip list?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#849 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAGMRIMA2JSRL3EUKUD5U4LSYHBUZANCNFSM4VMFSZ5A>.
|
Please note: py39 is experimental for us |
Yes, #684 was helpful to me to get as far as I got to.
For py39 with tk 8.6.10 I presume I have to compile python from scratch, which I can do but wanted to avoid, because python.org had some issues which forced them to go back to 8.6.8.
I’ll continue (as I find time) to see if I can get the python.org distribution to work.
Herm
… On Jan 4, 2021, at 10:43 AM, Marcelo Duarte ***@***.***> wrote:
Please note: py39 is experimental for us
I see some installed py39 with tk 8.6.10
Can you check if comments in issue #684 <#684> can help you?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#849 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAGMRIMCWUECVI6MOE4UAP3SYID63ANCNFSM4VMFSZ5A>.
|
I've tried the above with python 3.8.7 (instead of 3.9), downloaded from python.org, on Big Sur and the SampleTkApp.py behaves exactly the same, a completely black Tk window. |
otool inspection of library references in the frozen dylibs leads me to wonder if the Big Sur library cache somehow is related to this issue? |
Can you test the PR #887 (if you have a C compiler): |
Tested PR #887, although it didn't fix the tkinter black window issue it does fix needing these two setup lines (needed before due to capital T in Tkinter that got put into lib): Probably unrelated but on the tkinter sample still has the codesign issue on lib/Python. New issue, must manually chmod a+x the main program in .app/Contents/MacOS. Blocker: still black background for tkinter. |
Found a work around for python3.9 on mac Big Sur. Borrow tcl and tk 8.6.11 from python 3.10 0a3 as follows:
This seems to make tkinter operable again under cx_freeze (no more black window) |
No insights from me. I have not used tkinter in years, though I know there is a bunch of special code for dealing with it scattered around cx_freeze. |
Understood. I'm just saying that I know that tkinter gets special handling elsewhere in the code, but I am not sure if I should be adding anything special into darwintools.py. The fact the copying over the tcl/tk libraries from another version of python lets it work is a little strange! Hefischer—if it is not too much trouble, would you mind up-loading the output of "otool -l" for the original and replaced libraries? Thanks. |
Attached are the otool -lL from tkinter, tcl and tk of the 3.9 and 3.10 versions. libtcl-dylib-310-otool-lL.txt |
Thanks. I remember that I looked into tkinter before, and was confused about how it could work on Darwin under cx_Freeze. The issue is that tcl/tk have some directories of supporting tcl libraries that they appear to need to function. There is a hook in hooks.py ("load_tkinter()") to ensure that those files are copied, but the hook only functions on Windows (not on Darwin). My guess is that when the code was originally written, it was assumed that the user was using the built-in python, so did not need the tcl/tk support directories because they would also be on the user machine. I suspect that the work around above does not really create a good frozen app. It would work locally because the tcl/tk files are already installed there, but (I guess) would not work on a machine where they were not present. Do you have a clean Big Sur install (without python separately installed) that you could test it on? Not actually sure if this is the full explanation for the black windows (or if there are further issues), but I think it is something that needs to be addressed to get tkinter really working with cx_freeze. |
I'm using a shell script running after cx_freeze to straighten out the tk/tcl libraries. Testing on a VM under parallels for a "bare machine" Big Sur. Now struggling with code signing, which seems to require most python (such as numpy and matplotlib) to be under Resources, not MacOS. For now using a post-cx_Freeze script to try to straighten this out. but not done yet. |
I have another idea, maybe relates to Big Sur code signing requires otool-reported SDK > 10.9 but Python 3.9 has SDK 9.4.1. (Python 3.10a3 is SDK 11.1) I can't codesign the cx_frozen app because of old SDK of python 3.9 .so's. |
Agree, to cx_freeze for Mac after Big Sur and be both signed and notarized probably requires custom compiling Tcl/Tk, Python, major libraries (such as ssl) and pip-installables (those with .so or .dynlibs). All is difficult and will probably mean detailed instructions, or maybe we could have some kind of shell script (if anybody has loads of time). For product I support with cx_freeze (arelle.org) I've given up on sign/notarize for now, which is uncomfortable to end users. |
For what it is worth, my experience is that I use python installed via MacPorts and signing and notarization are working fine for me on Big Sur. There was one case where (if I am remembering correctly) I had a problem because MacPorts had installed a binary distribution of a package that had been built against an old SDK, but that was easy enough to fix by reinstalling the package form source. So maybe we can just direct people who have an issue to try using one of the package management systems, instead of the installer from python.org? Marcelo--thanks for the information about. Tkinter does seem to have its own special issues. I wonder if the original issue is about the program finding a different tcl/tk installation when running on a clean machine? We could do something like on windows and copy tcl/tk into the application bundle as well--but I'm not sure how to figure out which copy of tcl/tk tkinter is using... |
This worked for me! Thank you very much! |
facing the same issue, complete black screen, @hefischer workaround is complicated. why its not fixed yet in the distribution itself ? @hefischer can you suggest how to fix (for someone who are noob in python), will be very grateful. Thanks |
I believe that with python 3.10 this issue does not occur, since Tkinter was used from that version on python 3.9. |
@marcelotduarte Thank you so much, yes it's working fine now, and thanks again for the quick reply. |
@avi-arora Which 3.10 are you using . I am on 3.10 and it does not work , but I have to add that I am using an M1 12.3.1 not Big Sur Solved , had to use tk 8.6 |
@network-shark How did U switch to tk 8.6? I don't know how to switch tk. I've tried many py version including 3.10.4 and I get a black screen for every one. This has nothing to do with cx_freeze btw. |
@chrisdel101 I am using pyenv and I think I have used this tutorial. https://xogk39.medium.com/install-tkinter-on-mac-pyenv-f112bd3f4663 |
I made a PR to solve issues with Tkinter (read the comment).
|
cx_Freeze 6.12.0 has just been released. |
Current python (3.9.1) cx-Freeze (6.4.2) on samples/Tkinter (as well as other tkinter applications) causes a completely black Tk window on MacOS Big Sur (11.1). (Works fine when running from source.)
This is a blocker, any thoughts on a work around? (Compile 3.9 from scratch? Newer tkinter?)
(Also note that one must now "codesign --remove-signature lib/Python" inside the built App.)
The text was updated successfully, but these errors were encountered: