psycopg/Python.h:31:2: error: "psycopg requires Python 3.6"
#error "psycopg requires Python 3.6"
^
psycopg/Python.h:34:10: fatal error: 'structmember.h' file not found
#include <structmember.h>
^~~~~~~~~~~~~~~~
1 warning and 3 errors generated.
It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure× Encountered error while trying to install package.
╰─> psycopg2note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
折腾一个多小时没找到合适的解决方法,这里提供一种替代方法,可以解决程序报错问题,使程序正常运行,但红色波浪线会提示No module named 'psycopg2' 。
pip install psycopg2-binary