Psycopg2 import issue | spent 2 days wrestling with this

Hi everyone!

When I run my app locally, it’s all good!

I’m trying to deploy my app on cloud and getting this error:

ModuleNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you're on Streamlit Cloud, click on 'Manage app' in the lower right of your app).
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/", line 565, in _run_script
    exec(code, module.__dict__)
File "/app/streamlit_news/", line 5, in <module>
    import psycopg2

I tried adding it to my requirements.txt:


My folder structure is:



I feel like I did everything correctly! What’s the problem here? My import statements look like this:

import streamlit as st
import pandas as pd
import warnings
import datetime
import psycopg2

Please help! Thank you so much!

Hey @ccglz,

Can you share the full contents of your requirements.txt file so we can try to reproduce the issue?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.