Максим Суханов
07/08/2026, 10:07 AMNate
07/08/2026, 4:46 PMprefect version outputNate
07/08/2026, 4:57 PMdoes pip_install_requirements even work? I've checked the code, it installs requirements AFTER the process that will run the flow function was started, so it will not see any new dependencies, right?
Marvin
07/08/2026, 4:57 PMMarvin
07/08/2026, 4:59 PMpip_install_requirements runs in the workspace resolver subprocess, which prepares the run environment before Prefect starts the engine process that imports and executes the flow. So the flow process does see those installed dependencies.
Relevant code:
- Workspace starter spawns the resolver process first: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/_workspace_starter.py#L348-L365
- The resolver prepares the workspace and runs pull steps: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/_workspace_resolver.py#L290-L393
- deployment.pull_steps are executed here: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/_workspace_resolver.py#L362-L368
- pip_install_requirements itself does `python -m pip install -r ...`: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/deployments/steps/utility.py#L278-L338
- Only after that does Prefect start the engine process that runs the flow: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/_starter_engine.py#L27-L150
So the accurate explanation is:
runs after Prefect has started a prep/resolver subprocess, but before it starts the engine/flow subprocess. So newly installed dependencies are available to the flow run process.pip_install_requirements