TkinterWeb: HtmlFrame error on m1 macbook pro: incompatible architecture, and missing files
Source code snippet:
# gui2.py
import tkinter as tk
from tkinterweb import HtmlFrame
class GUI:
def __init__(self) -> None:
self.root = tk.Tk()
self.root.geometry("815x416")
self.info_html = HtmlFrame(self.root, width=1, height=1, horizontal_scrollbar="auto",
messages_enabled=False)
self.info_html.grid(row=0, column=0)
self.root.mainloop()
if __name__ == "__main__":
GUI()
Error:
$ python gui2.py
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.9/site-packages/tkinterweb/bindings.py", line 82, in __init__
load_tkhtml(master, folder)
File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.9/site-packages/tkinterweb/utilities.py", line 671, in load_tkhtml
master.tk.eval("package require Tkhtml")
_tkinter.TclError: dlopen(/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.9/site-packages/tkinterweb/tkhtml/Darwin/64-bit/Tkhtml30.dylib, 0x0006): tried: '/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.9/site-packages/tkinterweb/tkhtml/Darwin/64-bit/Tkhtml30.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/Tkhtml30.dylib' (no such file), '/usr/lib/Tkhtml30.dylib' (no such file)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/cuteufo/Projects/gui2.py", line 17, in <module>
tradematch_GUI()
File "/Users/cuteufo/Projects/gui2.py", line 9, in __init__
self.info_html = HtmlFrame(self.root, width=1, height=1, horizontal_scrollbar="auto",
File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.9/site-packages/tkinterweb/htmlwidgets.py", line 30, in __init__
self.html = html = TkinterWeb(self, message_func, HtmlFrame)
File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.9/site-packages/tkinterweb/bindings.py", line 85, in __init__
load_tkhtml(master, folder, force=True)
File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.9/site-packages/tkinterweb/utilities.py", line 671, in load_tkhtml
master.tk.eval("package require Tkhtml")
_tkinter.TclError: dlopen(/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.9/site-packages/tkinterweb/tkhtml/Darwin/64-bit/Tkhtml30.dylib, 0x0006): tried: '/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.9/site-packages/tkinterweb/tkhtml/Darwin/64-bit/Tkhtml30.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/Tkhtml30.dylib' (no such file), '/usr/lib/Tkhtml30.dylib' (no such file)
Environment:
miniforge3 arm64
Python 3.9.7
tkinterweb 3.10.7
MacOS 12.1 Monterey on MacBook Pro M1 Max
Other notes:
1. same code can be run without errors if I switch to anaconda packaged Python 3.8.5 (Intel) environment
2. same errors when running in either terminal command line or PyCharm, as long as with miniforge Python (arm64)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (7 by maintainers)
I’ve tried this new version of Tkhtml dylab. It works!🎉
Hi @cuteufo @pdebelak @damies13 @TsaiTung-Chen I’ve finally managed to compile Tkhtml using Github Actions. Apologies for the delay. Try extracting tkinterweb.zip and running
__init__.pyand let me know if it works.@Andereoo - yes, running
pip install tkinterwebnow works! I was able to run the example program from the readme.@TsaiTung-Chen @damies13 @cuteufo @pdebelak @TsaiTung-Chen @G-Donkey I have finally added support for M1 Macbooks. Apologies it took me so long! Please feel free to upgrade TkinterWeb and let me know if it works for you.
I have tried the
__init__.pyscript with the new “libTkhtml3.0.dylib” binary but failed and got the error message:BTW, it works fine if I replace the binary with this version.
Hi @TsaiTung-Chen, I don’t have a Mac to test on, so I have no way to debug that error. However, there are a few things you could try. For starters, don’t forget to include the following at the bottom of your code:
If you get the same issue, try setting
frame.set_maximum_thread_count(0)and let me know what happens!