Python -c "import _ports print != 'n/a']"īasically mentioned this in pyserial documentation Raise EnvironmentError('Unsupported platform')Įxcept (OSError, serial.SerialException): # this excludes your current terminal "/dev/tty"
import sysĪ list of the serial ports available on the system
#Python serial port example windows how to#
Instead I only get COM4 which seems to be connected to a modem (I don’t see it in the COM&LPT section of Device Manager)!ĭo you know why it doesn’t work? Have you got another solution which is not system specific? How to solve the problem: Solution 1: When my USB to COM gateway is connected to the PC (I see the COM5 in the Device Manager), this COM port isn’t included in the list returned by list_ports(). Print(list(_ports()))īut it seems that it doesn’t work. I have found in the pySerial API () a function _ports() that lists com ports (exactly what I want). I am using Python 3 with pySerial on a Windows 7 PC. I have found this method but it is Windows-specific: Listing serial (COM) ports on Windows? I am searching for a simple method to list all available com port on a PC. Question or problem about Python programming: