Hello John

On 29 November 2010 21:44, John Smith <jocj...@verizon.net> wrote:

> Hi, Walter -
> Thanks for all the research. This was my second attempt at installing the
> 2.4 version. I did it thus:
> E:\Python27\pyserial-2.4>..\python setup.py install
> standart distutils
> running install
> running build
> running build_py
> creating build
> creating build\lib
> creating 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\sermsdos.py -> build\lib\serial
> copying serial\__init__.py -> build\lib\serial
> running install_lib
> running install_egg_info
> Removing E:\Python27\Lib\site-packages\pyserial-2.4-py2.7.egg-info
> Writing E:\Python27\Lib\site-packages\pyserial-2.4-py2.7.egg-info
> E:\Python27\pyserial-2.4>
> But, when I tried it in Python, I got the same as before:
> >>> import serial
> >>> ser = serial.Serial(0, timeout = 1)
> >>> ser
> Serial<id=0x225c240, open=True>(port='COM1', baudrate=9600, bytesize=8,
> parity='N', stopbits=1, timeout=1, xonxoff=False, rtscts=False,
> dsrdtr=False)
> >>> ser.read()
> Traceback (most recent call last):
>  File "<pyshell#3>", line 1, in <module>
>    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.)
> >>>
I've checked and I think it was a mistake to suggest installing pyserial 2.4
on top of 2.5 without first removing 2.5 explicitly.  It appears that doing
so actually still retains the previous version of serialwin32.py in use,
based on the fact that I've manually had a look at serialwin32.py from both
pyserial2.4 and pyserial2.5 and that fact that line 236 in pyserial2.5 is
where the error is raised, and pySerial2.4 by contrast has "if err: #will be
ERROR_IO_PENDING:" on line 236.  Consequently this implies that you're still
using pyserial2.5 above.   (Aside: I originally tested my suggestion for
installing pyserial2.4 and tested it by importing the module (e.g. "import
serial") and then did a "help(serial)" which gave me the impression of it
having done the right thing and using pyserial2.4, but apparently that's not
definitve, or I made a mistake somewhere along the line and got the wrong
end of the stick.)

So. My apologies, but I think that suggestion has added to the confusion.

In any case, to fix it let's delete all instances of pySerial and then
install it again, as follows:

1.) Open up your Python "site-packages" folder in Windows Explorer, e.g.
open up:

2.) Delete any folder named "serial" that you may see.

3.) Delete any *file* name pyserial*.* that you may see, probably you'll see
"pyserial-2.4-py2.7.egg", there may also be an info file.

4.) Open up a Python shell and confirm that you can't import pyserial
anymore (e.g. "import serial" fails with e.g. "ImportError: No module named
serial".  If it still imports then you still have some vestiges of the
existing pyserial installation left over.

5.) After confirming the previous versions are gone, please try reinstalling
it again from scratch.  (E.g. extract source to some suitable place and run
"python setup.py install" from there, which copies the required files into
site-packages etc.)

6.) After installing, confirm "import serial" works again, then try your
test again.

Apologies again for adding to the confusion, and hopefully we're getting
closer. :-(

Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:

Reply via email to