[Tutor] Pyserial and invalid handle

Walter Prins wprins at gmail.com
Mon Nov 29 03:06:06 CET 2010


On 28 November 2010 15:55, John Smith <jocjo.s at verizon.net> wrote:

> Python 2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)]
> on win32
> Type "copyright", "credits" or "license()" for more information.
> >>> import serial
> >>> ser = serial.Serial('com1', timeout = 5)
> >>> x = ser.read()
> Traceback (most recent call last):
>  File "<pyshell#2>", line 1, in <module>
>    x = ser.read()
>  File "E:\Python27\lib\site-packages\serial\serialwin32.py", line 236, in
> read
>    raise SerialException("ReadFile failed (%s)" % ctypes.WinError())
> SerialException: ReadFile failed ([Error 6] The handle is invalid.)
> >>>

Ugh, you're probably not going to like this.  I've done some googling and it
appears this may be a 64-bit issue with the "ctypes" module... apparently
"64-bit ctypes can only import 64-bit libraries".  See here:

Then again, it also seems to be an open issue on the PySerial bug tracker:

Note, the above ticket suggests that PySerial 2.4 works ok (impliedly even
on 64-bit XP, so I imagine also on Windows 7.)  You should be able to try
this out by downloading the 2.4 version instead and installing it in the
same way you did the 2.5 version.  In any case, it might be an idea to post
a report/add a comment to that bug report as well to maybe help get this
issue resolved.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101129/0ce88784/attachment-0001.html>

More information about the Tutor mailing list