pySerial¶
This module encapsulates the access for the serial port. It provides backends for Python running on Windows, OSX, Linux, BSD (possibly any POSIX compliant system) and IronPython. The module named “serial” automatically selects the appropriate backend.
It is released under a free software license, see LICENSE for more details.
Copyright (C) 2001-2020 Chris Liechti <cliechti(at)gmx.net>
Other pages (online)
Features¶
- Same class based interface on all supported platforms.
- Access to the port settings through Python properties.
- Support for different byte sizes, stop bits, parity and flow control with RTS/CTS and/or Xon/Xoff.
- Working with or without receive timeout.
- File like API with “read” and “write” (“readline” etc. also supported).
- The files in this package are 100% pure Python.
- The port is set up for binary transmission. No NULL byte stripping, CR-LF translation etc. (which are many times enabled for POSIX.) This makes this module universally useful.
- Compatible with io library
- RFC 2217 client (experimental), server provided in the examples.
Requirements¶
- Python 2.7 or Python 3.4 and newer
- If running on Windows: Windows 7 or newer
- If running on Jython: “Java Communications” (JavaComm) or compatible extension for Java
For older installations (older Python versions or older operating systems), see older versions below.
Installation¶
This installs a package that can be used from Python ( import serial ).
To install for all users on the system, administrator rights (root) may be required.
From PyPI¶
pySerial can be installed from PyPI:
Using the python / python3 executable of the desired version (2.7/3.x).
Developers also may be interested to get the source archive, because it contains examples, tests and the this documentation.
From Conda¶
pySerial can be installed from Conda:
Currently the default conda channel will provide version 3.4 whereas the conda-forge channel provides the current 3.x version.
From source (zip/tar.gz or checkout)¶
Download the archive from http://pypi.python.org/pypi/pyserial or https://github.com/pyserial/pyserial/releases. Unpack the archive, enter the pyserial-x.y directory and run:
Using the python / python3 executable of the desired version (2.7/3.x).
Packages¶
There are also packaged versions for some Linux distributions:
- Debian/Ubuntu: “python-serial”, “python3-serial”
- Fedora / RHEL / CentOS / EPEL: “pyserial”
- Arch Linux: “python-pyserial”
- Gentoo: “dev-python/pyserial”
Note that some distributions may package an older version of pySerial. These packages are created and maintained by developers working on these distributions.
References¶
- Python: http://www.python.org/
- Jython: http://www.jython.org/
- IronPython: http://www.codeplex.com/IronPython
Older Versions¶
Older versions are still available on the current download page or the old download page. The last version of pySerial’s 2.x series was 2.7, compatible with Python 2.3 and newer and partially with early Python 3.x versions.
pySerial 1.21 is compatible with Python 2.0 on Windows, Linux and several un*x like systems, MacOSX and Jython.
On Windows, releases older than 2.5 will depend on pywin32 (previously known as win32all). WinXP is supported up to 3.0.1.
Name already in use
pyserial / documentation / pyserial.rst
- Go to file T
- Go to line L
- Copy path
- Copy permalink
3 contributors
Users who have contributed to this file
- Open with Desktop
- View raw
- Copy raw contents Copy raw contents
Copy raw contents
Copy raw contents
This module encapsulates the access for the serial port. It provides backends for Python running on Windows, OSX, Linux, BSD (possibly any POSIX compliant system) and IronPython. The module named «serial» automatically selects the appropriate backend.
It is released under a free software license, see LICENSE for more details.
Copyright (C) 2001-2020 Chris Liechti <cliechti(at)gmx.net>
Other pages (online)
- Same class based interface on all supported platforms.
- Access to the port settings through Python properties.
- Support for different byte sizes, stop bits, parity and flow control with RTS/CTS and/or Xon/Xoff.
- Working with or without receive timeout.
- File like API with «read» and «write» («readline» etc. also supported).
- The files in this package are 100% pure Python.
- The port is set up for binary transmission. No NULL byte stripping, CR-LF translation etc. (which are many times enabled for POSIX.) This makes this module universally useful.
- Compatible with :mod:`io` library
- RFC 2217 client (experimental), server provided in the examples.
- Python 2.7 or Python 3.4 and newer
- If running on Windows: Windows 7 or newer
- If running on Jython: «Java Communications» (JavaComm) or compatible extension for Java
For older installations (older Python versions or older operating systems), see older versions below.
This installs a package that can be used from Python ( import serial ).
To install for all users on the system, administrator rights (root) may be required.
pySerial can be installed from PyPI:
Using the python/python3 executable of the desired version (2.7/3.x).
Developers also may be interested to get the source archive, because it contains examples, tests and the this documentation.
pySerial can be installed from Conda:
Currently the default conda channel will provide version 3.4 whereas the conda-forge channel provides the current 3.x version.
From source (zip/tar.gz or checkout)
Download the archive from http://pypi.python.org/pypi/pyserial or https://github.com/pyserial/pyserial/releases. Unpack the archive, enter the pyserial-x.y directory and run:
Using the python/python3 executable of the desired version (2.7/3.x).
There are also packaged versions for some Linux distributions:
- Debian/Ubuntu: «python-serial», «python3-serial»
- Fedora / RHEL / CentOS / EPEL: «pyserial»
- Arch Linux: «python-pyserial»
- Gentoo: «dev-python/pyserial»
Note that some distributions may package an older version of pySerial. These packages are created and maintained by developers working on these distributions.
- Python: http://www.python.org/
- Jython: http://www.jython.org/
- IronPython: http://www.codeplex.com/IronPython
Older versions are still available on the current download page or the old download page. The last version of pySerial’s 2.x series was 2.7, compatible with Python 2.3 and newer and partially with early Python 3.x versions.
pySerial 1.21 is compatible with Python 2.0 on Windows, Linux and several un*x like systems, MacOSX and Jython.
On Windows, releases older than 2.5 will depend on pywin32 (previously known as win32all). WinXP is supported up to 3.0.1.
Pyserial install for Python 3.X (64bit windows)
C:\Users\User>python Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32 Type «help», «copyright», «credits» or «license» for more information.
pip install pyserial File «», line 1 pip install pyserial ^ SyntaxError: invalid syntax
Not sure why there is an error (perhaps this mode only work with LINUX / OSX?). Very curious.
Fairly certain from other postings that Win-32 bit pyserial installer will not work on Win64. Ideally, someone who has successfully installed pyserial on Win64 can weigh in and provide link / CLI install instructions. Spent hours Googling, but have not resolved this install.
![]()
2 Answers 2
Try installing PySerial from the command line in Windows. Just make sure ‘pip’ is in your PATH.
By the way, newer versions of PySerial have some bugs that might affect you on Windows (they did to me). If that happens simply install an earlier version of PySerial. I found that for me 2.7 works just fine.
The flag -I tells pip to ignore other versions and installs (or reinstalls) the defined one.
![]()
I am curious as to how many readers have successfully used the install process below. If your are successful please INDICATE by voting-up this response. PLEASE do not vote-up if you were not successful with the install procedure.
1) Downloaded and unzipped (WinRAR): pyserial3.0.1.gz to C:\Apps\pyserial
2) At DOS CLI: cd C:\Apps\pyserial
3) At DOS CLI: python setup.py install
C:\Apps\pyserial>python setup.py install
running install running bdist_egg running egg_info writing top-level names to pyserial.egg-info\top_level.txt writing dependency_links to pyserial.egg-info\dependency_links.txt writing pyserial.egg-info\PKG-INFO reading manifest file ‘pyserial.egg-info\SOURCES.txt’ reading manifest template ‘MANIFEST.in’ writing manifest file ‘pyserial.egg-info\SOURCES.txt’ installing library code to build\bdist.win-amd64\egg running install_lib running build_py creating build creating build\lib creating build\lib\serial copying serial\aio.py -> build\lib\serial copying serial\rfc2217.py -> build\lib\serial copying serial\rs485.py -> build\lib\serial copying serial\serialcli.py -> build\lib\serial copying serial\serialjava.py -> build\lib\serial copying serial\serialposix.py -> build\lib\serial copying serial\serialutil.py -> build\lib\serial copying serial\serialwin32.py -> build\lib\serial copying serial\win32.py -> build\lib\serial copying serial__init__.py -> build\lib\serial creating build\lib\serial\tools copying serial\tools\hexlify_codec.py -> build\lib\serial\tools copying serial\tools\list_ports.py -> build\lib\serial\tools copying serial\tools\list_ports_common.py -> build\lib\serial\tools copying serial\tools\list_ports_linux.py -> build\lib\serial\tools copying serial\tools\list_ports_osx.py -> build\lib\serial\tools copying serial\tools\list_ports_posix.py -> build\lib\serial\tools copying serial\tools\list_ports_windows.py -> build\lib\serial\tools copying serial\tools\miniterm.py -> build\lib\serial\tools copying serial\tools__init__.py -> build\lib\serial\tools creating build\lib\serial\urlhandler copying serial\urlhandler\protocol_alt.py -> build\lib\serial\urlhandler copying serial\urlhandler\protocol_hwgrep.py -> build\lib\serial\urlhandler copying serial\urlhandler\protocol_loop.py -> build\lib\serial\urlhandler copying serial\urlhandler\protocol_rfc2217.py -> build\lib\serial\urlhandler copying serial\urlhandler\protocol_socket.py -> build\lib\serial\urlhandler copying serial\urlhandler\protocol_spy.py -> build\lib\serial\urlhandler copying serial\urlhandler__init__.py -> build\lib\serial\urlhandler creating build\lib\serial\threaded copying serial\threaded__init__.py -> build\lib\serial\threaded creating build\bdist.win-amd64 creating build\bdist.win-amd64\egg creating build\bdist.win-amd64\egg\serial copying build\lib\serial\aio.py -> build\bdist.win-amd64\egg\serial copying build\lib\serial\rfc2217.py -> build\bdist.win-amd64\egg\serial copying build\lib\serial\rs485.py -> build\bdist.win-amd64\egg\serial copying build\lib\serial\serialcli.py -> build\bdist.win-amd64\egg\serial copying build\lib\serial\serialjava.py -> build\bdist.win-amd64\egg\serial copying build\lib\serial\serialposix.py -> build\bdist.win-amd64\egg\serial copying build\lib\serial\serialutil.py -> build\bdist.win-amd64\egg\serial copying build\lib\serial\serialwin32.py -> build\bdist.win-amd64\egg\serial creating build\bdist.win-amd64\egg\serial\threaded copying build\lib\serial\threaded__init__.py -> build\bdist.win-amd64\egg\serial\threaded creating build\bdist.win-amd64\egg\serial\tools copying build\lib\serial\tools\hexlify_codec.py -> build\bdist.win-amd64\egg\serial\tools copying build\lib\serial\tools\list_ports.py -> build\bdist.win-amd64\egg\serial\tools copying build\lib\serial\tools\list_ports_common.py -> build\bdist.win-amd64\egg\serial\tools copying build\lib\serial\tools\list_ports_linux.py -> build\bdist.win-amd64\egg\serial\tools copying build\lib\serial\tools\list_ports_osx.py -> build\bdist.win-amd64\egg\serial\tools copying build\lib\serial\tools\list_ports_posix.py -> build\bdist.win-amd64\egg\serial\tools copying build\lib\serial\tools\list_ports_windows.py -> build\bdist.win-amd64\egg\serial\tools copying build\lib\serial\tools\miniterm.py -> build\bdist.win-amd64\egg\serial\tools copying build\lib\serial\tools__init__.py -> build\bdist.win-amd64\egg\serial\tools creating build\bdist.win-amd64\egg\serial\urlhandler copying build\lib\serial\urlhandler\protocol_alt.py -> build\bdist.win-amd64\egg\serial\urlhandler copying build\lib\serial\urlhandler\protocol_hwgrep.py -> build\bdist.win-amd64\egg\serial\urlhandler copying build\lib\serial\urlhandler\protocol_loop.py -> build\bdist.win-amd64\egg\serial\urlhandler copying build\lib\serial\urlhandler\protocol_rfc2217.py -> build\bdist.win-amd64\egg\serial\urlhandler copying build\lib\serial\urlhandler\protocol_socket.py -> build\bdist.win-amd64\egg\serial\urlhandler copying build\lib\serial\urlhandler\protocol_spy.py -> build\bdist.win-amd64\egg\serial\urlhandler copying build\lib\serial\urlhandler__init__.py -> build\bdist.win-amd64\egg\serial\urlhandler copying build\lib\serial\win32.py -> build\bdist.win-amd64\egg\serial copying build\lib\serial__init__.py -> build\bdist.win-amd64\egg\serial byte-compiling build\bdist.win-amd64\egg\serial\aio.py to aio.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\rfc2217.py to rfc2217.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\rs485.py to rs485.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\serialcli.py to serialcli.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\serialjava.py to serialjava.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\serialposix.py to serialposix.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\serialutil.py to serialutil.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\serialwin32.py to serialwin32.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\threaded__init__.py to init.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\tools\hexlify_codec.py to hexlify_codec.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\tools\list_ports.py to list_ports.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\tools\list_ports_common.py to list_ports_common.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\tools\list_ports_linux.py to list_ports_linux.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\tools\list_ports_osx.py to list_ports_osx.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\tools\list_ports_posix.py to list_ports_posix.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\tools\list_ports_windows.py to list_ports_windows.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\tools\miniterm.py to miniterm.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\tools__init__.py to init.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\urlhandler\protocol_alt.py to protocol_alt.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\urlhandler\protocol_hwgrep.py to protocol_hwgrep.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\urlhandler\protocol_loop.py to protocol_loop.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\urlhandler\protocol_rfc2217.py to protocol_rfc2217.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\urlhandler\protocol_socket.py to protocol_socket.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\urlhandler\protocol_spy.py to protocol_spy.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\urlhandler__init__.py to init.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial\win32.py to win32.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\serial__init__.py to init.cpython-35.pyc creating build\bdist.win-amd64\egg\EGG-INFO installing scripts to build\bdist.win-amd64\egg\EGG-INFO\scripts running install_scripts running build_scripts creating build\scripts-3.5 copying and adjusting serial\tools\miniterm.py -> build\scripts-3.5 creating build\bdist.win-amd64\egg\EGG-INFO\scripts copying build\scripts-3.5\miniterm.py -> build\bdist.win-amd64\egg\EGG-INFO\scripts copying pyserial.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO copying pyserial.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO copying pyserial.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO copying pyserial.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO zip_safe flag not set; analyzing archive contents. creating dist creating ‘dist\pyserial-3.0.1-py3.5.egg’ and adding ‘build\bdist.win-amd64\egg’ to it removing ‘build\bdist.win-amd64\egg’ (and everything under it) Processing pyserial-3.0.1-py3.5.egg Copying pyserial-3.0.1-py3.5.egg to c:\users\user\appdata\local\programs\python\python35\lib\site-packages Adding pyserial 3.0.1 to easy-install.pth file Installing miniterm.py script to C:\Users\User\AppData\Local\Programs\Python\Python35\Scripts
Installed c:\users\user\appdata\local\programs\python\python35\lib\site-packages\pyserial-3.0.1-py3.5.egg Processing dependencies for pyserial==3.0.1 Finished processing dependencies for pyserial==3.0.
Arduino Lesson 17. Email Sending Movement Detector
You will be redirected back to this guide once you sign in, and can then subscribe to this guide.
If you are using a Mac or Linux computer, the Python is already installed. If you are using Windows, then you will need to install it. In either case, you will also need to install the PySerial library to allow communication with the Arduino.
To install Python on Windows, download the installer from http://www.python.org/getit/.
This project was built using Python 2.7.3
There are some reported problems with PySerial on Windows, using Python 3, so stick to Python 2.

Once Python is installed, you will find a new Program Group on your Start menu. However, we are going to make a change to Windows to allow you to use Python from the Command Prompt. You will need this to be able to install PySerial.
We are going to add something to the PATH environment variable.

To do this, you need to go to the Windows Control panel and find the System Properties control. Then click on the button labelled “Environment Variables” and in the window that pops-up select “Path” in the bottom section (System Variables). Click “Edit” and then at the end of the “Variable Value” without deleting any of the text already there, add the text: ;C:\Python27
Don’t forget the «;» before the new bit!
To test that it worked okay, start a new Command Prompt (DOS Prompt) and enter the command “python”. You should see something like this:

Whatever your operating system, download the .tar.gz install package for PySerial 2.6 from https://pypi.python.org/pypi/pyserial
This will give you a file called: pyserial-2.6.tar.gz
If you are using windows you need to uncompress this into a folder. Unfortunately, it is not a normal zip file, so you may need to download a tool such as 7-zip (http://www.7-zip.org/).
If you are using a Mac or Linux computer, then open a Terminal session, ‘cd’ to wherever you downloaded pyserial-2.6.tar.gz and then issue the following command to unpack the installation folder.
The rest of the procedure is the same whatever your operating system. Use you Comamnd Prompt / Terminal session and “cd” into the pyserial-2.6 folder, then run the command:

This guide was first published on Feb 28, 2013. It was last updated on Feb 28, 2013.
This page (Installing Python and PySerial) was last updated on Feb 28, 2013.