Not receiving UART data when disconnected from IDE

from pyb import UART

# UART 3, and baudrate.
uart = pyb.UART(3, 19200, timeout_char = 1000)
# OpenMV Cam Ground Pin   ----> Arduino Ground
# OpenMV Cam UART3_TX(P4) ----> Arduino UART_RX(0)
# OpenMV Cam UART3_RX(P5) ----> Arduino UART_TX(1)
# OpenMV Cam 5Vin to buck 
while(True):
        #print("No objects, sending x = ",1)
        uart.write("%d\n" % (1))
        while(True):
        #wait until arduino acknoledges, which writes a char to the H7 once the first packet of info is recieved.
            if(uart.readchar()!= -1):
            #write Y
                #print("No objects, sending y =", 1)
                uart.write("%d\n" % (1))
                break

Does not run in the IDE. Please post the code that runs in the IDE. When I try to run the above I get pyb not defined on line “uart = pyb.UART(3, 19200, timeout_char = 1000)” as you never imported pyb. You used from which is not an import.