This bogus error can be frustrating to figure out. I have figured it out a few times over the years and always forget how I solved it because it only occurs on a server where you have never deployed a python – postgres app. It’s easy once you know how.
apt-get install libpq-dev