pySerial and Arduino

Hello all! I have an irritating little problem!

I've been using the Serial module in python to transfer instructions to the Arduino. Sending the data appears to work fine, but after I've connected to the Arduino from my Python program I cannot open the serial monitor.

It just says 'Error opening serial port '/dev/cu.usbmodem1421'. (port busy)'

This makes it rather hard to debug the program, seeing as I don't know what's being fed into it. I have no idea if this is connected or not, but no serial connection can be established from the python program if the serial monitor is already open.

Also worth mentioning that this hasn't always happened, its a new and annoying development

So... any ideas??

Thank you for your help!

but after I've connected to the Arduino from my Python program I cannot open the serial monitor.

Of course you can't. There can only be one application at a time on the serial port.

This makes it rather hard to debug the program, seeing as I don't know what's being fed into it.

Why can't the python app read what the Arduino is sending, just like the Serial Monitor application does?

To extend what @PaulS has said it is a good idea to build code into your Python program that can identify debug messages from the Arduino for when you are testing. Your Python program could simply print them to the console. One option would be for the Arduino to preface its debug messages with "DBG"

If you write the debug handler as a Python function you will be easily able to copy it into any other Python program you may develop.

...R