PySerial
PySerialDocs

Installation

Install PySerial on Windows, Linux, and macOS with pip, conda, or system packages. Covers virtual environments, permissions, and troubleshooting.

Install PySerial and verify it works.

Install PySerial

pip install pyserial

Upgrade to latest:

pip install --upgrade pyserial

Pin a version:

pip install pyserial==3.5
conda install -c conda-forge pyserial
sudo apt update
sudo apt install python3-serial
sudo dnf install python3-pyserial
sudo pacman -S python-pyserial

Platform Setup

Windows

Install Python

Download from python.org. Check "Add Python to PATH" during installation.

Install PySerial

pip install pyserial

If you get a permission error:

pip install --user pyserial

Linux

Install

pip install pyserial

Fix Permissions

Serial ports require membership in the dialout group:

sudo usermod -a -G dialout $USER
newgrp dialout

Verify with groups. You should see dialout in the output.

Without dialout group membership, you'll get PermissionError when opening any /dev/tty* port.

macOS

brew install python3
pip3 install pyserial

macOS Catalina and later may require granting Full Disk Access to Terminal (System Preferences, Security and Privacy, Privacy tab).

Virtual Environments

python -m venv serial-project
source serial-project/bin/activate  # Linux/macOS
# serial-project\Scripts\activate   # Windows
pip install pyserial

Or with conda:

conda create -n serial-env python=3.11 pyserial
conda activate serial-env

Verify Installation

python -c "import serial; print(serial.__version__)"

Expected output: 3.5 (or your installed version).

List connected serial devices:

import serial.tools.list_ports

for port in serial.tools.list_ports.comports():
    print(f"{port.device}: {port.description}")

Log serial data automatically

TofuPilot records test results from your PySerial scripts, tracks pass/fail rates, and generates compliance reports. Free to start.

Troubleshooting

ModuleNotFoundError: No module named 'serial'

The PyPI package is pyserial, not serial. If you installed the wrong one:

pip uninstall serial
pip install pyserial

The import is import serial (not import pyserial).

Permission Denied (Linux)

sudo usermod -a -G dialout $USER
# Log out and back in, or run: newgrp dialout

Port Not Found

Check that your device is connected:

# Linux
ls /dev/tty{USB,ACM,S}*

# macOS
ls /dev/cu.* /dev/tty.*
import serial.tools.list_ports

for port in serial.tools.list_ports.comports():
    print(f"{port.device}: {port.description}")

Multiple Python Versions

python3.11 -m pip install pyserial

On Windows, use the py launcher:

py -3.11 -m pip install pyserial

Install from Source

git clone https://github.com/pyserial/pyserial.git
cd pyserial
pip install -e .