PySerial is a Python package that facilitates serial communication. A computer running Python with the PySerial package installed can communicate with external hardware. PySerial is a useful package for problem solvers because it allows us to exchange data between computers and pieces of external hardware such as voltmeters, oscilloscopes, strain gauges, flow meters, actuators, and lights.
PySerial provides an interface to communicate over the serial communication protocol. Serial communication is one of the oldest computer communication protocols. Serial communication protocol predates the USB specification used by computers and other pieces of hardware like mice, keyboards, and webcams. USB stands for Universal Serial Bus. USB and is built upon and extends the original serial communication interface.
To use the PySerial package with Python, PySerial first needs to be installed. If you installed the full Anaconda distribution of Python, PySerial comes pre-installed. If you do have the full Anaconda distribution of Python installed, PySerial can be installed using the Anaconda Prompt.
> conda install pyserial
Alternatively, PySerial can be installed on the command line using pip:
$ pip install pyserial
After PySerial is installed, the installation can be confirmed at the Python REPL:
>>> import serial >>> print(serial.version)
> conda install pyserial, the PySerial module is imported with the line