Python script works in the Editor but fails at Commandlet.

My script works in the Editor but fails when run from Cmdlet:

Command line:

"C:\Program Files\Epic Games\UE_4.21\Engine\Binaries\Win64\UE4Editor-Cmd.exe" "/path/to/my.uproject" -run=pythonscript -script="/path/to/"

The code:

import unreal as ue    
toselect = [ '/Game/Path/To/MyAsset1', '/Game/Path/To/MyAsset2', ]    

Running this from the Editor I would see the selected objects listed in the Content Browser’s main view.
However, other than a console window pops up (see screenshot), nothing happens in the Editor.

What am I missing?


Hello, have you resolved it? I have also encountered this issue. I hope to open the Unreal project file in an external Python editor and execute the Python script I executed in Unreal, but it only pops up a box and does not actually open the Unreal editor