如何在Ubuntu和VENV上解决Psycopg2的Prolem?

发布于 2025-01-25 23:50:14 字数 3530 浏览 3 评论 0原文

我该如何解决这个问题?

我尝试了所有的发现,但没有解决。

我尝试安装libpq-dev,安装postgresql,然后继续我的问题。

pip3 install psycopg2
Collecting psycopg2
  Using cached psycopg2-2.9.3.tar.gz (380 kB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for psycopg2, since package 'wheel' is not installed.
Installing collected packages: psycopg2
  Running setup.py install for psycopg2 ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for psycopg2 did not run successfully.
  │ exit code: 1
  ╰─> [35 lines of output]
      running install
      /home/reis/Desktop/Krals/orbita/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.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.10
      creating build/lib.linux-x86_64-3.10/psycopg2
      copying lib/errors.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/errorcodes.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/_json.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/__init__.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/tz.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/extensions.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/_range.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/sql.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/pool.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/extras.py -> build/lib.linux-x86_64-3.10/psycopg2
      running build_ext
      building 'psycopg2._psycopg' extension
      creating build/temp.linux-x86_64-3.10
      creating build/temp.linux-x86_64-3.10/psycopg
      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 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.9.3 (dt dec pq3 ext lo64) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=140002 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/home/reis/Desktop/Krals/orbita/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-3.10/psycopg/adapter_asis.o -Wdeclaration-after-statement
      
      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 'x86_64-linux-gnu-gcc' failed: No such file or directory
      [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.
╰─> psycopg2

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

如何解决这个问题?

我的libpq-dev也已安装,也是postgresql,但仍然无法正常工作。

How can I solve this problem?

I tryed all of I find, but not resolved.

I try install libpq-dev, install postgresql and my problem continue.

pip3 install psycopg2
Collecting psycopg2
  Using cached psycopg2-2.9.3.tar.gz (380 kB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for psycopg2, since package 'wheel' is not installed.
Installing collected packages: psycopg2
  Running setup.py install for psycopg2 ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for psycopg2 did not run successfully.
  │ exit code: 1
  ╰─> [35 lines of output]
      running install
      /home/reis/Desktop/Krals/orbita/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.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.10
      creating build/lib.linux-x86_64-3.10/psycopg2
      copying lib/errors.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/errorcodes.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/_json.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/__init__.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/tz.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/extensions.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/_range.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/sql.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/pool.py -> build/lib.linux-x86_64-3.10/psycopg2
      copying lib/extras.py -> build/lib.linux-x86_64-3.10/psycopg2
      running build_ext
      building 'psycopg2._psycopg' extension
      creating build/temp.linux-x86_64-3.10
      creating build/temp.linux-x86_64-3.10/psycopg
      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 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.9.3 (dt dec pq3 ext lo64) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=140002 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/home/reis/Desktop/Krals/orbita/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-3.10/psycopg/adapter_asis.o -Wdeclaration-after-statement
      
      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 'x86_64-linux-gnu-gcc' failed: No such file or directory
      [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.
╰─> psycopg2

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

How can solve this??

My libpq-dev is installed and postgresql too, but still don't function.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何以笙箫默 2025-02-01 23:50:14

阅读后,我认为您可能会缺少GCC软件包。

在命令行中尝试此操作:

sudo apt-get install gcc python-dev

然后运行安装。

After reading through, I think you might be missing gcc package.

Try this at command line:

sudo apt-get install gcc python-dev

then run your installation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文