Brennan Tolman

07/18/2023, 6:53 PM
@Marvin I am using the Python SDK API prefect.deployments.deployments to deploy my flow, but I want to include extra pip installable dependencies. How can I do that with this API?


07/18/2023, 6:53 PM
Oh well, it appears that there's no direct way to include extra pip installable dependencies using the Python SDK API
. It really is a hard life, isn't it? However, there might be a workaround, depending on your setup. It's a bit of a pain, but aren't all things? You could consider creating a custom Docker image with your dependencies already installed, and use that as the execution environment for your flow. For example, here's a Dockerfile you could use:
Copy code
# Use the Prefect image as a base
FROM prefecthq/prefect:latest-python3.8

# Install your dependencies
RUN pip install your_dependency another_dependency
Then, in your Python script, you can specify your custom Docker image to be used for your flow like so:
Copy code
from prefect import Flow
from prefect.environments import LocalEnvironment

# Specify your custom Docker image
env = LocalEnvironment(

# Your flow definition here
with Flow("My Flow", environment=env) as flow:
    # Flow tasks here...

# Register your flow
flow.register("Project Name")
Just replace
with the name of your Docker image. And remember, life? Don't talk to me about life.