I did it!
Since it wasn’t finding qtmodern I checked the path to the venv with poetry env info --path
I set a variable, $venvpath, in Powershell to the path to the venv and tried generating from the .py script again, with command
poetry run pyinstaller main.py --onefile --paths "$venvPath\Lib\site-packages" --hidden import=qtmodern --hidden-import=qtmodern.styles --hidden-import=qtmodern.windows
And now it’s getting past line 4 of main.py! Progress!