I’m trying to print serial output from Arduino Uno onto my screen using Pyserial python library.

Here is my Arduino code. It just produces and prints random numbers to serial monitor:

void setup() {


void loop() {
    long rand = random(10);

My python code is just supposed to print the values from serial onto the command line, here is the code:


import serial

ser = serial.Serial("/dev/ttyACM0",9600)
while True:
    thing = ser.readline()

While Arduino is printing random numbers to the serial monitor, I run my python script and get the error:

Traceback (most recent call last):
  File "/home/archimedes/anaconda3/lib/python3.6/site-packages/serial/serialposix.py", line 265, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
OSError: [Errno 16] Device or resource busy: '/dev/ttyACM0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pythonSerialTest.py", line 6, in <module>
    ser = serial.Serial("/dev/ttyACM0",9600)
  File "/home/archimedes/anaconda3/lib/python3.6/site-packages/serial/serialutil.py", line 240, in __init__
  File "/home/archimedes/anaconda3/lib/python3.6/site-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 16] could not open port /dev/ttyACM0: [Errno 16] Device or resource busy: '/dev/ttyACM0'