Error: pg_config executable not found

操作系统

root@BM01-cyzx-sqmyfxyppt-001:/jy# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

安装

psycopg2==2.9.9

报错

Collecting psycopg2==2.9.9 (from -r requirements.txt (line 40))
  Using cached https://mirrors.aliyun.com/pypi/packages/c9/5e/dc6acaf46d78979d6b03458b7a1618a68e152a6776fce95daac5e0f0301b/psycopg2-2.9.9.tar.gz (384 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      running egg_info
      writing psycopg2.egg-info/PKG-INFO
      writing dependency_links to psycopg2.egg-info/dependency_links.txt
      writing top-level names to psycopg2.egg-info/top_level.txt
      
      Error: pg_config executable not found.
      
      pg_config is required to build psycopg2 from source.  Please add the directory
      containing pg_config to the $PATH or specify the full executable path with the
      option:
      
          python setup.py build_ext --pg-config /path/to/pg_config build ...
      
      or with the pg_config option in 'setup.cfg'.
      
      If you prefer to avoid building psycopg2 from source, please install the PyPI
      'psycopg2-binary' package instead.
      
      For further information please check the 'doc/src/install.rst' file (also at
      <https://www.psycopg.org/docs/install.html>).
      
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

在这里插入图片描述
解决办法

sudo apt-get install libpq-dev

再次重新安装

当出现"pg_config executable not found"错误时,这意味着在安装psycopg2时找不到pg_config可执行文件。pg_configPostgreSQL的一个工具,用于提供有关PostgreSQL安装的信息。 解决此错误的方法之一是确保pg_config可执行文件位于系统的PATH环境变量中。您可以按照以下步骤操作: 1. 找到pg_config可执行文件的路径。通常情况下,它位于PostgreSQL安装目录的bin文件夹中。 2. 将pg_config可执行文件的路径添加到系统的PATH环境变量中。具体步骤取决于您使用的操作系统。 - 在Windows上,您可以按照以下步骤操作: - 在开始菜单中搜索"环境变量"并打开"编辑系统环境变量"。 - 在系统属性对话框中,点击"环境变量"按钮。 - 在"系统变量"部分,找到名为"Path"的变量,并点击"编辑"。 - 在编辑环境变量对话框中,点击"新建"并添加pg_config可执行文件的路径。 - 点击"确定"保存更改。 - 在Linux上,您可以编辑您的bash配置文件(例如~/.bashrc或/etc/profile)并将pg_config可执行文件的路径添加到PATH变量中。例如: ```shell export PATH=/path/to/pg_config:$PATH ``` 然后运行以下命令使更改生效: ```shell source ~/.bashrc ``` 3. 重新运行安装psycopg2的命令,应该不再出现"pg_config executable not found"错误。 请注意,如果您没有PostgreSQL安装或不需要使用psycopg2,您可以考虑使用其他适合您需求的库。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值