Python, Pyserial on windows 7 PC Com port problems

Hey I’m new to Arduino but I am really enjoying it so far!

I am trying to get this to work:

http://principialabs.com/arduino-python-4-axis-servo-control/

I installed Python 2.7 along with Pyserial 2.5 just to follow the instructions exactly. I am running Windows 7 64 bit on a PC. When I run the servo.py module I usually get this error or it comes up after I try to import the servo:

import servo

Traceback (most recent call last):
File “<pyshell#0>”, line 1, in
import servo
File “C:\Python27\servo.py”, line 29, in
ser = serial.Serial(usbport, 9600, timeout=1)
File “C:\Python27\lib\site-packages\serial\serialwin32.py”, line 30, in init
SerialBase.init(self, *args, **kwargs)
File “C:\Python27\lib\site-packages\serial\serialutil.py”, line 260, in init
self.open()
File “C:\Python27\lib\site-packages\serial\serialwin32.py”, line 56, in open
raise SerialException(“could not open port %s: %s” % (self.portstr, ctypes.WinError()))
SerialException: could not open port com8: [Error 5] Access is denied.

I have read that I need to give python administrator access but I’m not sure how to do that.

File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 56, in open
    raise SerialException("could not open port %s: %s" % (self.portstr, ctypes.WinError()))
SerialException: could not open port com8: [Error 5] Access is denied.

does not look like a problem importing the servo package, to me. Looks to me like you are trying to open a serial port, and the process was not granted access to the port.

Is that the port that the Arduino is connected to? Is the Serial Monitor open?

Yes, it is the port that the board is connected to.

No, the serial monitor for the IDE is not open (although i have tried it with it open too).

I have also tried removing the usb dongle for my wireless mouse because according to my device manager there is only one COM port (COM8) for all three usb connections. I dont see why this would be a problem since I have had several usb devices connected at once without issue. I have also tried disabling, then enabling COM8 to try to free it up.

after reading a bit online about com access problems I downloaded the program “portmon” to try to figure out who is occupying the port but I can’t get the stupid thing to work of course. i think i was getting “error 2” when trying to connect if anyone is familiar with it.

I tried running python 3.2 64bit with the pre-release version of pywin and pyserial to go with it. same problem.

Any ideas?

In python you have to put the port you see in arduino - 1.

eg: my port in arduino IDE = 8 then you put 7 in python.

ser = serial.Serial(7, 9600, timeout=1)

hope it helps.