[Tutor] Importing serial module
dyoo at hkn.eecs.berkeley.edu
Mon Aug 22 07:50:42 CEST 2005
On Mon, 22 Aug 2005, Hans Dushanthakumar wrote:
> 1) I downloaded the python serial port module (pyserial-2.2.win32.exe)
> from http://sourceforge.net/project/showfiles.php?group_id=46487
> And installed it on my Win XP PC.
> However, when I try to import the module, I get the foll: error
> >>> import serial
> Traceback (most recent call last):
> File "<pyshell#61>", line 1, in ?
> import serial
> File "C:\Python\Lib\site-packages\serial\__init__.py", line 13, in ?
> from serialwin32 import *
> File "C:\Python\Lib\site-packages\serial\serialwin32.py", line 9, in ?
> import win32file # The base COM port and file IO functions.
> ImportError: No module named win32file
> Is there something else that I need to specify?
The 'win32file' module should be a part of the 'win32api' package.
win32api doesn't come installed by default: I think you might need to
grab the win32api package. You can grab it here:
> 2) I want to send data (ascii text) to a serial port, but at the same
> time want to keep monitoring incoming data in that same serial port.
> Whats the best approach to do this? Multithreading? Or is there a more
> straightforward/easier approach?
Multithreading should work.
An alternative approach involves asynchronous event-handling. The Twisted
framework mentioned earlier today appears to have support for serial
Best of wishes!
More information about the Tutor