semuconsulting/PyGPSClient

Aborts on macOS 13.2.1 with couldn't recognize data in image file iconmonstr-location-27-32.png

Closed this issue · 5 comments

After installing on macOS 13.2.1 with

python3 -m pip install --upgrade PyGPSClient

and then launching with

python3 -m pygpsclient

the program aborts immediately with following output:

Me@Mac-Studio ~ % python3 -m pygpsclient
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/klingler/Library/Python/3.9/lib/python/site-packages/pygpsclient/__main__.py", line 43, in <module>
    main()
  File "/Users/klingler/Library/Python/3.9/lib/python/site-packages/pygpsclient/__main__.py", line 37, in main
    App(root, **kwargs)
  File "/Users/klingler/Library/Python/3.9/lib/python/site-packages/pygpsclient/app.py", line 118, 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/Me/Library/Python/3.9/lib/python/site-packages/pygpsclient/resources/iconmonstr-location-27-32.png"

Hi @richardklingler

Sorry you're having difficulties, but I can only imagine you have a corrupted installation somehow.

PyGPSClient runs fine under MacOS 13.2.* on both Intel and M1/M2 platforms and Python versions >=3.7, <=3.11. The image file in question appears in the About dialog - see screen shots below.

I've not come across that 'Tk deprecation' warning before on a Mac - there may be something odd about your Python installation. It may be worth upgrading to the latest Python 3.11 (alongside 3.9 if necessary) to see if that resolves the problem, or re-installing Python 3.9 via the Mac 64-bit Universal Installer (https://www.python.org/ftp/python/3.9.13/python-3.9.13-macos11.pkg).

Screenshot 2023-03-08 at 08 22 07

Screenshot 2023-03-08 at 08 05 42

Fiddled around a bit and tried installing 3.11.2 via pyenv...no joy...

Only this helped:

brew install python-tk

Hi @richardklingler

Glad you got it sorted, but I'm surprised you had to do a brew install of python-tk on MacOS - this is typically only necessary on some Linux platforms.

The standard universal Python installation package for MacOS (from python.org, not the App Store) includes all the necessary tkinter runtimes and environment configuration. I've never needed to install brew or macports on any of my Mac workstations.

https://www.python.org/ftp/python/3.11.2/python-3.11.2-macos11.pkg

 $ python3 -m pip install --upgrade pygpsclient
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pygpsclient in ./Library/Python/3.9/lib/python/site-packages (1.3.30)
Requirement already satisfied: requests>=2.28.0 in ./Library/Python/3.9/lib/python/site-packages (from pygpsclient) (2.31.0)
Requirement already satisfied: Pillow>=9.0.0 in ./Library/Python/3.9/lib/python/site-packages (from pygpsclient) (10.0.0)
Requirement already satisfied: pygnssutils>=1.0.11 in ./Library/Python/3.9/lib/python/site-packages (from pygpsclient) (1.0.11)
Requirement already satisfied: pyserial>=3.5 in ./Library/Python/3.9/lib/python/site-packages (from pygpsclient) (3.5)
Requirement already satisfied: pyspartn>=0.1.10 in ./Library/Python/3.9/lib/python/site-packages (from pygpsclient) (0.1.10)
Requirement already satisfied: paho-mqtt>=1.6.1 in ./Library/Python/3.9/lib/python/site-packages (from pygnssutils>=1.0.11->pygpsclient) (1.6.1)
Requirement already satisfied: pyubx2>=1.2.28 in ./Library/Python/3.9/lib/python/site-packages (from pygnssutils>=1.0.11->pygpsclient) (1.2.28)
Requirement already satisfied: cryptography>=39.0.2 in ./Library/Python/3.9/lib/python/site-packages (from pyspartn>=0.1.10->pygpsclient) (41.0.2)
Requirement already satisfied: charset-normalizer<4,>=2 in ./Library/Python/3.9/lib/python/site-packages (from requests>=2.28.0->pygpsclient) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in ./Library/Python/3.9/lib/python/site-packages (from requests>=2.28.0->pygpsclient) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in ./Library/Python/3.9/lib/python/site-packages (from requests>=2.28.0->pygpsclient) (2.0.4)
Requirement already satisfied: certifi>=2017.4.17 in ./Library/Python/3.9/lib/python/site-packages (from requests>=2.28.0->pygpsclient) (2023.5.7)
Requirement already satisfied: cffi>=1.12 in ./Library/Python/3.9/lib/python/site-packages (from cryptography>=39.0.2->pyspartn>=0.1.10->pygpsclient) (1.15.1)
Requirement already satisfied: pynmeagps>=1.0.27 in ./Library/Python/3.9/lib/python/site-packages (from pyubx2>=1.2.28->pygnssutils>=1.0.11->pygpsclient) (1.0.27)
Requirement already satisfied: pyrtcm>=1.0.11 in ./Library/Python/3.9/lib/python/site-packages (from pyubx2>=1.2.28->pygnssutils>=1.0.11->pygpsclient) (1.0.11)
Requirement already satisfied: pycparser in ./Library/Python/3.9/lib/python/site-packages (from cffi>=1.12->cryptography>=39.0.2->pyspartn>=0.1.10->pygpsclient) (2.21)
MacBook-Air:~ brandon 2023-07-28 14:52:43 $ pygpsclient
/Users/brandon/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:34: NotOpenSSLWarning: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
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 "/Users/brandon/Library/Python/3.9/bin/pygpsclient", line 8, in <module>
    sys.exit(main())
  File "/Users/brandon/Library/Python/3.9/lib/python/site-packages/pygpsclient/__main__.py", line 47, in main
    App(root, **kwargs)
  File "/Users/brandon/Library/Python/3.9/lib/python/site-packages/pygpsclient/app.py", line 130, 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/brandon/Library/Python/3.9/lib/python/site-packages/pygpsclient/resources/iconmonstr-location-27-32.png"

Hi @brandonros

The clue is in the error message:

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.

As is mentioned in the README.md, the version of Python that is preinstalled on MacOS includes a deprecated version of tkinter (8.5). God only knows why - it's been deprecated for nearly 10 years now. You'll need to upgrade this to the latest version 8.6, and by far the easiest way to do this is to simply install Python using the official Python.org MacOS 'universal2' installer, which works for both Intel and Apple Silicon:

https://www.python.org/downloads/release/python-3114/

I STRONGLY RECOMMEND against using brew or macports to install python or tkinter - that will almost certainly lead to a corrupted installation.

If you want to check the version of tkinter you're running, you can run the following script:

import tkinter
tkinter.TkVersion

To find the low level version, use:

import tkinter
tcl = tkinter.Tcl()
print(tcl.call("info", "patchlevel"))

Hope this helps