I keep getting this error when trying to have a sc...
# prefect-community
k
I keep getting this error when trying to have a scheduled run from a deployed flow. It runs fine as a non-deployed flow (when I run it from my terminal). I built and applied the deployment on another flow/script and it worked (but it also doesn’t have any non-prefect imports). Should I
import psycopg2
from somewhere else instead? Running 2.3.2
Copy code
Flow could not be retrieved from deployment.
Traceback (most recent call last):
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/tmp/tmpcre52tf5prefect/SCRIPTNAME.py", line 3, in <module>
    import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
1
n
Hey @kiran 👋 what infrastructure are you using for your deployment? I'd guess that you might be using the prefect base image that doesn't have psycopg2 installed, whereas you do have it installed locally to check this theory, you could add
{"EXTRA_PIP_PACKAGES": "psycopg2"}
to the
env
section of your infrastructure block, which will install it each time the flow runs (somewhat inefficient) and then the cleanest solution would be to
pip install psycopg2
wherever your flows will run (i.e. from your
requirements.txt
in a Dockerfile or in a venv on some VM where your agent runs)