当我安装 psyxopg2 时,出现以下错误。有谁能帮我解决一下吗...
\nCollecting psycopg2\n\n Using cached psycopg2-2.9.3.tar.gz (380 kB)\n\n Preparing metadata (setup.py) ... done\n\nBuilding wheels for collected packages: psycopg2\n\n Building wheel for psycopg2 (setup.py) ... error\n\n error: subprocess-exited-with-error\n\n \n\n \xc3\x97 python setup.py bdist_wheel did not run successfully.\n\n \xe2\x94\x82 exit code: 1\n\n \xe2\x95\xb0\xe2\x94\x80> [40 lines of output]\n\n /home/vedvund/PycharmProjects/postgreSQLDatabaseusingPython /venv/lib/python3.10/site-packages/setuptools/config/setupcfg.py:463: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.\n\n warnings.warn(msg, warning_class)\n\n running bdist_wheel\n\n running build\n\n running build_py\n\n creating build\n\n creating build/lib.linux-x86_64-cpython-310\n\n creating build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/_ipaddress.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/__init__.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/errors.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/tz.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/_json.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/extras.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/errorcodes.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/extensions.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/pool.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/sql.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/_range.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n running build_ext\n\n building 'psycopg2._psycopg' extension\n\n creating build/temp.linux-x86_64-cpython-310\n\n creating build/temp.linux-x86_64-cpython-310/psycopg\n\n x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC "-DPSYCOPG_VERSION=2.9.3 (dt dec pq3 ext lo64)" -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=140004 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 "-I/home/vedvund/PycharmProjects/postgreSQLDatabaseusingPython /venv/include" -I/usr/include/python3.10 -I. -I/usr/include/postgresql -I/usr/include/postgresql/14/server -I/usr/include/libxml2 -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-cpython-310/psycopg/adapter_asis.o -Wdeclaration-after-statement\n\n In file included from psycopg/adapter_asis.c:28:\n\n ./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory\n\n 36 | #include <libpq-fe.h>\n\n | ^~~~~~~~~~~~\n\n compilation terminated.\n\n \n\n It appears you are missing some prerequisite to build the package from source.\n\n \n\n You may install a binary package by installing 'psycopg2-binary' from PyPI.\n\n If you want to install psycopg2 from source, please install the packages\n\n required for the build and try again.\n\n \n\n For further information please check the 'doc/src/install.rst' file (also at\n\n <https://www.psycopg.org/docs/install.html>).\n\n \n\n error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1\n\n [end of output]\n\n \n\n note: This error originates from a subprocess, and is likely not a problem with pip.\n\n ERROR: Failed building wheel for psycopg2\n\n Running setup.py clean for psycopg2\n\nFailed to build psycopg2\n\nInstalling collected packages: psycopg2\n\n Running setup.py install for psycopg2 ... error\n\n error: subprocess-exited-with-error\n\n \n\n \xc3\x97 Running setup.py install for psycopg2 did not run successfully.\n\n \xe2\x94\x82 exit code: 1\n\n \xe2\x95\xb0\xe2\x94\x80> [42 lines of output]\n\n /home/vedvund/PycharmProjects/postgreSQLDatabaseusingPython /venv/lib/python3.10/site-packages/setuptools/config/setupcfg.py:463: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.\n\n warnings.warn(msg, warning_class)\n\n running install\n\n /home/vedvund/PycharmProjects/postgreSQLDatabaseusingPython /venv/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.\n\n warnings.warn(\n\n running build\n\n running build_py\n\n creating build\n\n creating build/lib.linux-x86_64-cpython-310\n\n creating build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/_ipaddress.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/__init__.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/errors.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/tz.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/_json.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/extras.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/errorcodes.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/extensions.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/pool.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/sql.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n copying lib/_range.py -> build/lib.linux-x86_64-cpython-310/psycopg2\n\n running build_ext\n\n building 'psycopg2._psycopg' extension\n\n creating build/temp.linux-x86_64-cpython-310\n\n creating build/temp.linux-x86_64-cpython-310/psycopg\n\n x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC "-DPSYCOPG_VERSION=2.9.3 (dt dec pq3 ext lo64)" -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=140004 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 "-I/home/vedvund/PycharmProjects/postgreSQLDatabaseusingPython /venv/include" -I/usr/include/python3.10 -I. -I/usr/include/postgresql -I/usr/include/postgresql/14/server -I/usr/include/libxml2 -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-cpython-310/psycopg/adapter_asis.o -Wdeclaration-after-statement\n\n In file included from psycopg/adapter_asis.c:28:\n\n ./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory\n\n 36 | #include <libpq-fe.h>\n\n | ^~~~~~~~~~~~\n\n compilation terminated.\n\n \n\n It appears you are missing some prerequisite to build the package from source.\n\n \n\n You may install a binary package by installing 'psycopg2-binary' from PyPI.\n\n If you want to install psycopg2 from source, please install the packages\n\n required for the build and try again.\n\n \n\n For further information please check the 'doc/src/install.rst' file (also at\n\n <https://www.psycopg.org/docs/install.html>).\n\n \n\n error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1\n\n [end of output]\n\n \n\n note: This error originates from a subprocess, and is likely not a problem with pip.\n\nerror: legacy-install-failure\n\n\n\n\xc3\x97 Encountered error while trying to install package.\n\n\xe2\x95\xb0\xe2\x94\x80> psycopg2\n\n\n\nnote: This is an issue with the package mentioned above, not pip.\n\nhint: See above for output from the failure.\n
Run Code Online (Sandbox Code Playgroud)\n
重复的错误似乎是:
./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
这是以前遇到过的问题。解决方案是使用:
sudo apt-get install --reinstall libpq-dev
Run Code Online (Sandbox Code Playgroud)
重新安装该软件包。检查这个答案,它深入探讨了这个问题。