Raspberry Pi 3B+ BLE communication to Arduino Nano 33 IOT
For completeness, it appears an appropriate Python library can be installed with:
pip3 install adafruit-circuitpython-ble

The test code, used with the Arduino code 'Echo' from the ArduinoHardwareBLE library is below.  This was updated to let you choose the name of the device (here, MY_BLE)  rather than any random device that has UART capability.  It also allows you to send a small file from a few lines, with a &quot;#&quot; denoting a comment (first character in the line).  ESC and a return quits the program.
# Connect to an &quot;eval()&quot; service over BLE UART.
 
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService

ble = BLERadio()
 
uart_connection = None

def send_stuff(s):
    uart_service.write(s.encode(&quot;utf-8&quot;))
    uart_service.write(b'\n')
    readline=uart_service.readline().decode(&quot;utf-8&quot;)
    while(len(readline)&gt;0):
        print(readline)
        readline=uart_service.readline().decode(&quot;utf-8&quot;)
            
while True:
    

    if not uart_connection:
        print(&quot;Trying to connect...&quot;)
        print(&quot;ESC then RETURN to exit.&quot;)
        for adv in ble.start_scan(ProvideServicesAdvertisement):
            if UARTService in adv.services:
                regular_name = adv.complete_name
                if(regular_name=='MY_BLE'):
                    uart_connection = ble.connect(adv)
                    print(&quot;Connected&quot;)
                    # for some reason, we have to read a line...
                    uart_service = uart_connection[UARTService]
                    print(uart_service.readline().decode(&quot;utf-8&quot;))
                    break
        ble.stop_scan()
 
    if uart_connection and uart_connection.connected:
        uart_service = uart_connection[UARTService]
        while uart_connection.connected:
            s = input(&quot;Prompt: &quot;)
            if(len(s)&gt;0):
                if(ord(s[0])==27):
                    print(&quot;done.&quot;)
                    exit()
                else:
                    
                    # Check if &quot;!&quot; character is used; if so, send contents of a file
                    if(s[0]==&quot;!&quot;):
                        print(&quot;sending commands&quot;)
                        count=0
                        file1=open('commands.txt','r')
                        Lines=file1.readlines()
                        for line in Lines:
                            count=count+1
                            tmp=line.strip()
                            if(len(tmp)&gt;0):
                                if(tmp[0]=='#'):
                                    print(&quot;comment:&quot; + tmp)
                                else:
                                    print(&quot;Line{}: {}&quot;.format(count, tmp))
                                    send_stuff(tmp)
                
                    else:
                        send_stuff(s)