Deepin 20 深度系统安装 PyGreSQL 报错解决办法

  最近在做一个项目有些数据需要从一个PostgreSQL数据库中读取,安装PyGreSQL 时遇到了一些问题,将问题及解决办法附上。

错误1:pg_config: not found

    Complete output from command python setup.py egg_info:
    /bin/sh: 1: pg_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-c4i8o_ca/PyGreSQL/setup.py", line 90, in <module>
        pg_version = pg_version()
      File "/tmp/pip-install-c4i8o_ca/PyGreSQL/setup.py", line 84, in pg_version
        match = re.search(r'(\d+)\.(\d+)', pg_config('version'))
      File "/tmp/pip-install-c4i8o_ca/PyGreSQL/setup.py", line 76, in pg_config
        raise Exception("pg_config tool is not available.")
    Exception: pg_config tool is not available.

解决办法,安装postgresql客户端及libpq-dev 即可

sudo apt-get install postgresql libpq-dev

错误2:pgmodule.c:14:10: fatal error: Python.h

pgmodule.c:14:10: fatal error: Python.h: 没有那个文件或目录
     #include <Python.h>
              ^~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

解决办法;

安装python-dev ,需要注意的是如果直接安装后依然报错,就讲指定安装当前python版本,如下所示:

sudo apt-get install python3.7-dev

版权所有©艾克斯记事-转载文章请注明出处(带链接)

发表评论

电子邮件地址不会被公开。 必填项已用*标注