https://prefect.io logo
Title
j

jpuris

09/18/2022, 5:41 PM
Heya! I’m new to prefect and am trying to deploy a local agent
prefect deployment build flows/redshift_mv_refresh.py:redshift_mv_refresh --name JPMBP-O --queue JPMBP-O --tag "redshift mv-refresh test" --infra process
However I’m running into an issue where the
deployment build
command tests the main flow and hence fails as it can not import some of the modules provided by a virtual env.
...
    import redshift_connector
ModuleNotFoundError: No module named 'redshift_connector'
...
prefect.exceptions.ScriptError: Script at 'flows/redshift_mv_refresh.py' encountered an exception
An exception occurred.
my project’s directory
❯ tree . -L 2
.
├── flows
│   ├── __pycache__
│   ├── lib
│   └── redshift_mv_refresh.py
├── requirements.txt
└── venv
    ├── bin
    ├── include
    ├── lib
    └── pyvenv.cfg
How can I tell
deployment build
to look for python in
venv/bin/python
Thank you a bunch! edit: I’m using Prefect 2 with Cloud.
3
a

Anna Geller

09/18/2022, 7:06 PM
Venv is a bit weird, can you try the same in a Conda environment? You would need to ensure your agent gets deployed to the same virtual environment as the one you used to run your flows locally Generally, this redshift connector module seems missing in your execution layer
j

jpuris

09/18/2022, 8:11 PM
Thanks! Will try this with conda and report back.
👍 1
:thank-you: 1
Looks like it is working! I’ll be using miniconda from now on! 🙂 Thank you again!