https://prefect.io logo
Title
c

Charles Leung

03/10/2023, 10:56 PM
Hi everyone, I’ve been running into an
NotImplementedError
when using the prefect_shell collection. It was working previously but for some reason when I tried doing it again it’s not working. I’ve already used pip install -U prefect-shell and double checked that its installed correctly in the venv Lib But when running a simple test I get the following “Not Implemented” error: The source code can be found below:
from prefect import flow
from prefect_shell import shell_run_command

@flow
def example_shell_run_command_flow():
return shell_run_command(command="ls .", return_all=True)

if name == "main":
print("test")
example_shell_run_command_flow()
error message from the cloud UI is attached.

Error_msg

1569×931 120 KB

Any help would be appreciated. Thanks!
n

Nate

03/11/2023, 12:41 AM
Hi @Charles Leung I'm not on windows, so I'm not able to reproduce exactly, but I'm wondering if this works for you instead?
from prefect_shell import ShellOperation

ShellOperation(commands=["ls ."]).run()
ShellOperation
is not a task, but can be wrapped in a
task
if desired.
shell_run_command
is still a thing for the sake of backwards compatibility, but recommend the use of
ShellOperation
c

Charles Leung

03/11/2023, 12:57 AM
Hey Nate, yeah I tried using ShellOperation when debugging, but no dice. Still returning the same error
n

Nate

03/11/2023, 1:00 AM
hmm, what version of python are you on?
c

Charles Leung

03/11/2023, 1:03 AM
3.8.8
🤔 1
n

Nate

03/12/2023, 2:29 AM
I think from this, that windows requires a different asyncio event loop policy that we don't yet seem to support, can you try placing this before your
shell_run_command
call?
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
c

Charles Leung

03/13/2023, 5:23 PM
hmm no dice unfortunately. But i found that trying it on Pycharm worked for some reason? However doing it on Visual Studio doesnt
n

Nate

03/13/2023, 5:31 PM
hmm. it sounds like one way or another it must be an environment issue you’re encountering when outside of PyCharm would you be willing to open an issue on prefect-shell describing your setup and the error?