How do you send G-code from a USB port with Python?
The process is pretty straightforward, you open a serial connection and send the instructions over the serial connection. The printer reports &quot;OK&quot; when received (not when the command has been executed).
You can use pySerial to connect to a USB port with the correct speed, then send the command you want to execute (include the newline char).
You need to be aware that commands are buffered, if the buffer is full, the printer sends &quot;OK&quot; when there is a spot free in the buffer.
See this question on a sister SE.