This message was deleted.
# ask-marvin
s
This message was deleted.
m
Your message was too long by 295 tokens - please shorten it and try again. For reference, here's your message at the allowed limit:
My deployment's Docker doesn't have psycopg2 included. All my deployments fail, and when I look at the docker logs it's states such. I've included it in my prefect.yaml but I still get the same error. Why is this occurring? Here's my prefect.yaml file:
```# Welcome to your prefect.yaml file! You can use this file for storing and managing # configuration for deploying your flows. We recommend committing this file to source # control along with your flow code. # Generic metadata about this project name: marketing prefect-version: 3.0.10 # build section allows you to manage and build docker images build: - prefect.deployments.steps.run_shell_script: id: get-commit-hash script: git rev-parse --short HEAD stream_output: false - prefect.deployments.steps.run_shell_script: id: get-prefect-version script: prefect --version stream_output: false - prefect_docker.deployments.steps.build_docker_image: requires: prefect-docker>=0.3.0 image_name: 10.10.4.100:5000/get_app_list_landing tag: '{{ get-prefect-version.stdout }}-{{ get-commit-hash.stdout }}' # TODO: Change this full directory before you check in to Git dockerfile: /home/myusername/development/marketing/src/p
n
hi @Klashe are you trying to use psycopg in your flow code? are you unable to build your image to include that binary psycopg library?
i.e. why cant you do that in your Dockerfile?
k
Hi @Nate, thanks for the reply. I am trying to use psycopg in my flow code. My image builds successfully with pip install psycopg2-binary but when the container runs it's states that it cannot find it.
n
I would guess that there's some python path mismatch are you doing anything fancy with venv's in your Dockerfile?
k
No i'm not touching the venv in my docker. Here's the Dockerfile:
Copy code
FROM prefecthq/prefect:3.0.10-python3.10

ARG EXTRA_PIP_PACKAGES="psycopg2-binary"
RUN pip install $EXTRA_PIP_PACKAGES
And the error I receive is this:
Copy code
File "/usr/local/lib/python3.12/site-packages/prefect/utilities/importtools.py", line 168, in load_script_as_module
    raise ScriptError(user_exc=exc, path=path) from exc
prefect.exceptions.ScriptError: Script at 'src/etl/landing/vendor/get_app_list_landing_etl_prefect.py' encountered an exception: ModuleNotFoundError("No module named 'psycopg2'")
01:11:33.340 | ERROR   | prefect.flow_runs.runner - Process for flow run 'stereotyped-skink' exited with status code: 1
01:11:33.396 | INFO    | prefect.flow_runs.runner - Reported flow run '6c7ee467-1007-4131-a23b-d8abc80b6704' as crashed: Flow run process exited with non-zero status code 1.
01:11:33.639 | INFO    | prefect.deployment - Cloned repository '<http://10.10.4.100:3302/me/marketing.git>' into 'marketing-main'
 > Running git_clone step...
If I shell into the docker, pip freeze shows psycopg2:
Copy code
prefect @ file:///opt/prefect/dist/prefect.tar.gz#sha256=35bc6e270751ee081b37857e67a73d9492a690534ed418d49370a5bc22658ed2
prefect-docker==0.6.1
prometheus_client==0.21.0
prompt_toolkit==3.0.47
protobuf==5.28.1
psutil==6.0.0
psycopg2-binary==2.9.9            <---------
n
hrmm I still think it might be some python path thing going on where is your worker running? this is working for me (i.e. the job starts and then it fails bc im not actually running postgres, but we import fine) • prefect.yamlrequirementsDockerfileflow code
🙌 1
k
Thank you! Let me review and I will see what the difference are. Tremendous help.