It is true! You are right.
pcbnew package is not visible on system Python but is on Pcbnew console. So it is under some environment.
Tracking my debugging step: on Linux, the launch file (“shortcut”) have the content like
#!/bin/sh
. /usr/share/kicad-nightly/kicad-nightly.env
/usr/lib/kicad-nightly/bin/kicad "$@"
The `` file
export LD_LIBRARY_PATH=/usr/lib/kicad-nightly/lib/x86_64-linux-gnu/:/usr/lib/kicad-nightly/lib/
export KICAD_PATH=/usr/share/kicad-nightly
And inside ${LD_LIBRARY_PATH}/python3/dist-packages there are the pcbnew.py and _pcbnew.so (compiled) files.
Just checking how to create a “clean command” do include such information on “Execute Command Job Settings” for Jobsets: Execute Command (iBom?) - #6 by hildogjr.