NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » pyserial on windows 7
May 01, 2011 by kle8309 |
I have been having permission problem with windows 7 when I try reading from
the serial port. import serial import sys serial = serial.Serial("COM5", 115200) while True: data = serial.read() if data == 1: print "1" if data == 2: print "2" else: print "0" print "--" This is the error from the windows python gui (ver 2.6.6) Traceback (most recent call last): File "C:Python26serialRead.py", line 4, in <module> serial = serial.Serial("COM5", 115200) File "C:Python26libsite-packagesserialserialwin32.py", line 30, in init SerialBase.init(self, args, *kwargs) File "C:Python26libsite-packagesserialserialutil.py", line 260, in init self.open() File "C:Python26libsite-packagesserialserialwin32.py", line 56, in open raise SerialException("could not open port %s: %s" % (self.portstr, ctypes.WinError())) SerialException: could not open port COM5: [Error 5] Access is denied. |
---|---|
May 01, 2011 by kle8309 |
|
May 01, 2011 by kle8309 |
|
May 01, 2011 by Ralphxyz |
kle8309, are you sure you are using "COM5" ? Ralph |
May 01, 2011 by kle8309 |
Ralph yes, I checked my devices and it's COM5 This setup worked on the linux but not windows. |
May 01, 2011 by hevans (NerdKits Staff) |
Hi kle8309, Try opening the command line from which you run the python script as Administrator. Humberto |
May 01, 2011 by kle8309 |
YES!!!
Thank you Humberto, that solved everything. I have been spending hours to find an alternative solution toward serial communication like c++ and visual basic (I got visual basic to work) But python is much easier to play with. |
Please log in to post a reply.
Did you know that our kits have shipped to hobbyists in 40 countries? Learn more...
|