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)

here is my conf

  platform: command_line
      command_on: "/usr/bin/python3 --version"
      command_off: "/usr/bin/python3 /home/homeassistant/"

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/

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

How did you install Home Assistant - Hassbian, Docker,, 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