0

hi guys i want to access a port but i got access denied error in anaconda IDE i even tried virtual port programs and got same error

serial = serial.Serial(port='COM8', baudrate=250000)

and this is the error:

could not open port 'COM8': PermissionError(13, 'Access is denied.', None, 5)
blackbrandt
  • 2,010
  • 1
  • 15
  • 32
arian
  • 41
  • 1
  • 11
  • Possible duplicate of [Trying to open a serial port with pyserial on WinXP -> "Access denied"](https://stackoverflow.com/questions/2063257/trying-to-open-a-serial-port-with-pyserial-on-winxp-access-denied) – Mike Doe Sep 04 '18 at 08:39
  • thanks but none of them worked for me – arian Sep 04 '18 at 08:56

1 Answers1

0

I don't know if you found your answer yet. But my issue was getting that error immediately after running my program more than once without closing that port. I used serial.close() to fix my problem.

import serial 

with serial.Serial('COM8', 9600, serial.EIGHTBITS,timeout=0,parity=serial.PARITY_NONE, 
rtscts=1) as ser:
  print(ser.is_open)
  ser.close()

I would recommend closing the port each time you are finished using the port to avoid access issues.

Theo
  • 3
  • 1