Command line failed but works with cli

Hi I want to run this python script with a command line switch:

import serial
ser = serial.Serial('/dev/ttyS1', 9600)
ser.write(bytearray('5','ascii'))

here is my conf

switch:
  platform: command_line
  switches:
    arest_pin_four:
      command_on: "/usr/bin/python3 --version"
      command_off: "/usr/bin/python3 /home/homeassistant/testSerial.py"

so this is a test but the on command works (easy of course)
but the off fails

[homeassistant.components.switch.command_line] Command failed:/usr/bin/python3 /home/homeassistant/testSerial.py

what is strange is that the command works in shell interface (with the user homeassistant): /usr/bin/python3 /home/homeassistant/testSerial.py

How did you install Home Assistant - Hassbian, Docker, Hass.io, Synology, something else?

I’ve intalled it on an orange pi with armbian python 3 virtual env.
I’m wondering if it could be that the pyserial lib should installed specifically in the virtual env.
I’m looking to the doc actually

Yes, you’ll need any library you’re using installed in the venv