From cb2060c0d768da38c9aa463e315e187a91f761f8 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 26 Aug 2020 13:41:14 +1000 Subject: [PATCH] Workaround failure to import pyserial list_ports on MacOS Big Sur Preview References: https://github.com/espressif/esptool/issues/540 https://github.com/pyserial/pyserial/issues/509 The fix will probably come in a Python update before the Big Sur final release, there is a bundle of PRs including an apparent fix for the underlying issue here: https://bugs.python.org/issue41100 --- esptool.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/esptool.py b/esptool.py index 2eecc7e84..5f0c860bc 100755 --- a/esptool.py +++ b/esptool.py @@ -60,6 +60,13 @@ print("The installed version (%s) of pyserial appears to be too old for esptool.py (Python interpreter %s). " "Check the README for installation instructions." % (sys.VERSION, sys.executable)) raise +except Exception: + if sys.platform == "darwin": + # swallow the exception, this is a known issue in pyserial+macOS Big Sur preview ref https://github.com/espressif/esptool/issues/540 + list_ports = None + else: + raise + __version__ = "3.0-dev" @@ -3309,6 +3316,9 @@ def add_spi_flash_subparsers(parent, is_elf2image): initial_baud = args.baud if args.port is None: + if list_ports is None: + raise FatalError("Listing all serial ports is currently not available on this operating system version. " + "Specify the port when running esptool.py") ser_list = sorted(ports.device for ports in list_ports.comports()) print("Found %d serial ports" % len(ser_list)) else: