From 7a83a06c922b5554830624173b7f11b45fe99b2d Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 20 Dec 2018 17:12:59 +1100 Subject: [PATCH] esptool: Add some clarification if list_ports is missing Closes https://github.com/espressif/esptool/issues/350 Also fixes regression in detecting wrong 'serial' module (see https://github.com/espressif/esptool/issues/269) --- esptool.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/esptool.py b/esptool.py index 337883c28..6cd33d378 100755 --- a/esptool.py +++ b/esptool.py @@ -32,9 +32,12 @@ import time import zlib import string -import serial.tools.list_ports as list_ports -import serial +try: + import serial +except ImportError: + print("Pyserial is not installed for %s. Check the README for installation instructions." % (sys.executable)) + raise # check 'serial' is 'pyserial' and not 'serial' https://github.com/espressif/esptool/issues/269 try: @@ -50,6 +53,12 @@ except TypeError: pass # __doc__ returns None for pyserial +try: + import serial.tools.list_ports as list_ports +except ImportError: + 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 __version__ = "2.6-beta1"