[python] No module named serial

and I got a question when I run my Python code.

I installed Python 2.7 on Windows 7, bit 64. I got an error "No module named serial" when I compiled my code:

import serial

ser = serial.Serial("COM5", 9600)

ser.write("Hello world")

x = ser.readline()

print(x)

I tried many ways to crack this problem, such as installed Canopy to setup virtual environment, make sure 'pip' is there, no Python v 3.x installed. But still cannot get it out.

Any advice would be appreciated.

This question is related to python

The answer is


Download this file :- (https://pypi.python.org/packages/1f/3b/ee6f354bcb1e28a7cd735be98f39ecf80554948284b41e9f7965951befa6/pyserial-3.2.1.tar.gz#md5=7142a421c8b35d2dac6c47c254db023d):

cd /opt
sudo tar -xvf ~/Downloads/pyserial-3.2.1.tar.gz -C .
cd /opt/pyserial-3.2.1 
sudo python setup.py install 

First use command

pip uninstall pyserial

Then run again

 pip install pyserial

The above commands will index it with system interpreter.


You do not have serial package installed.

Try pip install serial to install the module.

Alternatively, install it in binary form from here:

Install Pyserial for Windows

Note that you always install precompiled binaries at your own risk.


it may be very old post, but I would like to share my experience. I had the same issue when I used Pycharm and I installed the package from Project Interpreter page in the Project Settings/Preferences... That fixed the issue, please check below link: https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html?_ga=2.41088674.1813230270.1594526819-1842497340.1594080707


You must pip install pyserial first.


Serial is not included with Python. It is a package that you'll need to install separately.

Since you have pip installed you can install serial from the command line with:

pip install pyserial

Or, you can use a Windows installer from here. It looks like you're using Python 3 so click the installer for Python 3.

Then you should be able to import serial as you tried before.


In my case the command below did the job

pip3 install pyserial

You must have the pyserial library installed. You do not need the serial library.Therefore, if the serial library is pre-installed, uninstall it. Install the pyserial libray. There are many methods of installing:-

  1. pip install pyserial
  2. Download zip from pyserial and save extracted library in Lib>>site-packages folder of Python.
  3. Download wheel and install wheel using command: pip install <wheelname>

Link: https://github.com/pyserial/pyserial/releases

After installing Pyserial, Navigate to the location where pyserial is installed. You will see a "setup.py" file. Open Power Shell or CMD in the same directory and run command "python setup.py install". Now you can use all functionalities of pyserial library without any error.


  1. Firstly uninstall pyserial using the command pip uninstall pyserial
  2. Then go to https://www.lfd.uci.edu/~gohlke/pythonlibs/
  3. download the suitable pyserial version and then go to the directory where the file is downloaded and open cmd there
  4. then type pip install "filename"(without quotes)