Python Pyserial Windows No Port Found
Question: I have just tried to connect to usb mobile to send sms through it using AT
commands. But when i use pyserial to connect to it in a windows os, i get
error could not open port, the file specified cannot be found.

    
    
    >>> import serial
    >>> ser = serial.Serial(0)  # open first serial port
    >>> print ser.name          # check which port was really used
    >>> ser.write("hello")      # write a string
    >>> ser.close()  
    

even if i replace the 0 with any other value, like 0 -10 or 'com0','com1' etc,
i still get error file specified not found, port cannot be open.

There is a command listed in pyserial documentation which lists ports or
allows you to open a port

python -m serial.tools.miniterm

This command is supposed to list all serial ports. But it shows none.

I have 3 usb ports on my system. What is causing this issue.


Answer: Pyserial is _not_ guaranteed to detect all ports. This depends on how the
device and the OS communicate and if pyserial is designed to pick up on this.
For Example, pyserial could not detect a LabJack U3-LV or a EPSOM-POS receipt
printer I plugged in in a Win8 session (both could be detected using a linux
session).

Try **serial.tools.list_ports.comports()** and see what it gives you.

You could also look at the **pyusb** module for usb connections.

_Also_ : I recommend being careful when using numbers for ports, as the
mapping may not be "common-sense" logical (i.e. 0 may not map to COM0). Use
explicit string names instead.

