./psycopg/psycopg.h:31:22: fatal error: libpq-fe.h: No such file or directory

yum install libpqxx-devel

pip install psycopg2后就web.py可以happy的访问数据库了