0

I am trying to compile a python code with cx_freeze in Windows 7, python 2.7, but it keeps giving me trouble because of pyserial. I tried to import the pyserial tools module in many different ways but I keep getting compilation errors:

import serial
import serial.tools
from serial.tools import list_ports

#I also tried:
#import serial.tools.list_ports
#from serial import tools
#import serial.tools.list_ports
#from serial import tools

The error message varies between: ImportError: No module named tools and ImportError: No module named tools.list_ports

Any ideas on how to solve this issue? Thanks.

Lightwave
  • 1
  • 1
  • It seems that pySerial is not installed. – Vadim Shkaberda May 24 '16 at 15:06
  • Thanks for the comment but I am sure that pySerial is installed. I can read/write to com ports without a problem. The issues appears when I try to compile the code with cx_freeze. Before that there is no error message. – Lightwave May 25 '16 at 00:36
  • If you have multiple versions of Python, pySerial is, probably, not installed for version you currently use. Check [this post](http://stackoverflow.com/questions/10919569/how-to-install-a-module-use-pip-for-specific-version-of) or [this post](http://stackoverflow.com/questions/5991193/installing-modules-for-multiple-python-versions). If it worked in current version, maybe, [this post](http://stackoverflow.com/a/15622021/5510499) helps. If nothing helps, try to reinstall pySerial. – Vadim Shkaberda May 25 '16 at 05:18
  • Thanks Vadim. I just solved the issue. Turns out that pySerial was installed from a different directory and somehow cx_freeze was not finding it. I simply copied the whole serial directory to: "C:\Python27\Lib\site-packages\" and the problem has been solved. – Lightwave May 25 '16 at 06:49

0 Answers0