Hi! I am wondering if anyone is able to use ShellT...
# ask-community
m
Hi! I am wondering if anyone is able to use ShellTask on Windows? I'm running a script from tutorial and getting an error:
Copy code
from prefect import Flow
from prefect.tasks.shell import ShellTask

task = ShellTask(helper_script="cd ~")

with Flow("My Flow") as f:
    contents = task(command='ls')
        
out = f.run()
Copy code
[2021-02-26 10:32:28+1100] INFO - prefect.FlowRunner | Beginning Flow run for 'My Flow'
[2021-02-26 10:32:28+1100] INFO - prefect.TaskRunner | Task 'ShellTask': Starting task run...
[2021-02-26 10:32:28+1100] ERROR - prefect.TaskRunner | Unexpected error: FileNotFoundError(2, 'The system cannot find the file specified', None, 2, None)
Traceback (most recent call last):
.....
....
python\python38-32\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
I do have bash installed, also specifying path doesn't help
task = ShellTask(shell="C:\Windows\System32\bash.exe", helper_script="cd ~")
z
Hi @Maria -- I believe it should work. I'm surprised specifiying the full path doesn't do it.
We're using Python's
subprocess.Popen([shell])
-- if you open an interactive python session and do
Copy code
import subprocess
process = subprocess.Popen(["C:\Windows\System32\bash.exe"])
For example, on my machine this gets me
Copy code
❯ python                    
Python 3.8.6 (default, Feb 19 2021, 10:36:24) 
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.Popen(["bash"])
<subprocess.Popen object at 0x10115ea00>
>>> 
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit <https://support.apple.com/kb/HT208050>.
bash-3.2$
m
Hi @Zanie, I'm getting same error when I call subprocess in an interactive python session
I saw many posts on stakeoverflow with this error, and the recommendation is usually pass shell=True as an argument. I'm getting "somewhat" further if I do that:
Copy code
>>> subprocess.Popen("C:\Windows\System32\bash.exe", shell=True)
<subprocess.Popen object at 0x039AE718>
>>> The filename, directory name, or volume label syntax is incorrect.
I also found this which seems similar to what I experience: https://github.com/PrefectHQ/prefect/issues/3790
z
Looks like it's broken on Windows! That one fell through the cracks. We'll work on a fix 👍
🙏 1
m
thanks!
t
Sorry to revive this thread. Is there any progress on resolving this?
z
Eek. I'm sorry. I'll open an issue so this gets resolved -- barring some sort of surprising complication it'll be fixed today.
@Marvin open "`ShellTask` does not work on Windows"
t
thanks so much!!
This took me forever 🤦‍♂️ haha
Windows is tough