diff --git a/Tools/px_uploader.py b/Tools/px_uploader.py index aa25560a64..3f628eaed6 100755 --- a/Tools/px_uploader.py +++ b/Tools/px_uploader.py @@ -56,7 +56,6 @@ from __future__ import print_function import sys import argparse import binascii -import serial import socket import struct import json @@ -68,6 +67,16 @@ import os from sys import platform as _platform +try: + import serial +except ImportError as e: + print("Failed to import serial: " + str(e)) + print("") + print("You may need to install it using:") + print(" pip3 install --user pyserial") + print("") + sys.exit(1) + # Detect python version if sys.version_info[0] < 3: runningPython3 = False @@ -726,29 +735,6 @@ def main(): print("WARNING: You should uninstall ModemManager as it conflicts with any non-modem serial device (like Pixhawk)") print("==========================================================================================================") - # We need to check for pyserial because the import itself doesn't - # seem to fail, at least not on macOS. - pyserial_installed = False - try: - if serial.__version__: - pyserial_installed = True - except: - pass - - try: - if serial.VERSION: - pyserial_installed = True - except: - pass - - if not pyserial_installed: - print("Error: pyserial not installed!") - print("") - print("You may need to install it using:") - print(" pip3 install --user pyserial") - print("") - sys.exit(1) - # Load the firmware file fw = firmware(args.firmware) diff --git a/Tools/setup/requirements.txt b/Tools/setup/requirements.txt index 2e95aa65c2..c4af02e354 100644 --- a/Tools/setup/requirements.txt +++ b/Tools/setup/requirements.txt @@ -15,7 +15,7 @@ pygments wheel>=0.31.1 pymavlink pyros-genmsg -pyserial>=3.0 +pyserial pyulog>=0.5.0 pyyaml requests