https://prefect.io logo
#prefect-community
Title
# prefect-community
j

John Kang

05/25/2022, 6:04 PM
Hi all, I'm thinking of using a shelltask and activating a specific virtual environment using the
helper_script
argument. Does anyone have any idea how I would write that script up?
k

Kevin Kho

05/25/2022, 6:06 PM
You mean like a conda environment or venv?
I would just attempt
helper_script="conda activate myenv"
but I honestly don’t know if it will stick. I guess you can try that and then check the python version
Your bash (or shell of choice) needs to be able to support the command i think
I can’t get it to work. Looks like more configuration has to be done but you can test like this:
Copy code
from prefect.tasks.shell import ShellTask

shell = ShellTask(helper_script="source ~/anaconda3/bin/activate fugue_tutorials", return_all=True,
log_stderr=True, stream_output=True)
shell.run(command = "pip show fugue")
j

John Kang

05/25/2022, 6:22 PM
@Kevin Kho Got it! I'll try it out. Thanks for looking into this.
6 Views