semuconsulting / PyGPSClient

Python Graphical GPS Client Application supporting NMEA, UBX, RTCM3, NTRIP & SPARTN Protocols
BSD 3-Clause "New" or "Revised" License
521 stars 104 forks source link

Unable to start the Tk on Mac m1 #62

Closed Lynn1996 closed 1 year ago

Lynn1996 commented 1 year ago

Sorry sir, I just followed the guideline and try to run the pygpsclient. I type in python3 -m pygpsclient The console gives error:

DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/frank/PyGPSClient-master/src/pygpsclient/__main__.py", line 49, in <module>
    main()
  File "/Users/frank/PyGPSClient-master/src/pygpsclient/__main__.py", line 43, in main
    App(root, **kwargs)
  File "/Users/frank/PyGPSClient-master/src/pygpsclient/app.py", line 135, in __init__
    self.__master.iconphoto(True, PhotoImage(file=ICON_APP))
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 4064, in __init__
    Image.__init__(self, 'photo', name, cnf, master, **kw)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 4009, in __init__
    self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "/Users/frank/PyGPSClient-master/src/pygpsclient/resources/iconmonstr-location-27-32.png"

My python3 version is 3.9.6, and Tk is 8.5. I installed pillow by brew.

semuadmin commented 1 year ago

Hi @Lynn1996

Tcl/Tk 8.6 has been available for over 10 years now - the latest supported version of Tk is 8.6.13.

Assuming you have a Mac made in the past 10 years or so, you shouldn't need to use brew (or macports) to install the necessary Python stack or dependencies. I strongly recommend you uninstall your brew version and simply use the latest official download from Python.org, which includes Tcl/Tk 8.6 and the necessary imaging libraries and works fine on all modern MacOS platforms including M1/M2 e.g. https://www.python.org/ftp/python/3.11.3/python-3.11.3-macos11.pkg. I use a MacBook Pro M1 Max running Ventura 13.3.1 myself and have had no difficulties with this install.

(Python 3.11 is recommended, but downloads for earlier versions from 3.7 to 3.10 are also available if you prefer)

You should find everything runs fine on an official Python.org MacOS install. I'll update the README.md to clarify this.

FYI here's the official statement from Python:

"If you are using macOS 10.6 or later, the Apple-supplied Tcl/Tk 8.5 has serious bugs that can cause application crashes. If you wish to use IDLE or Tkinter, do not use the Apple-supplied Pythons. Instead, install and use a newer version of Python from python.org or a third-party distributor that supplies or links with a newer version of Tcl/Tk."

Lynn1996 commented 1 year ago

Dear semuadmin

Amazing! I am using Mac M1 Pro and installed the latest Python version. Everything works now!

Many thanks!