From afdb8632ba6f6265ce35b2d2475a8207661ceffc Mon Sep 17 00:00:00 2001
From: Adam Blank <blank@caltech.edu>
Date: Sun, 20 Oct 2024 04:31:49 +0000
Subject: [PATCH] Update ports.py

---
 ports.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/ports.py b/ports.py
index 6087c6b..e5793a2 100644
--- a/ports.py
+++ b/ports.py
@@ -1,6 +1,15 @@
-import serial
-import serial.tools
+import subprocess
 import sys
+
+try:
+    import serial
+    import serial.tools
+except ImportError:
+    subprocess.check_call([sys.executable, "-m", "pip", "install", 'pyserial'])
+finally:
+    import serial
+    import serial.tools
+
 import time
 
 import serial.tools.list_ports
-- 
GitLab