首页 > 解决方案 > 无法在 Centos 上安装 PyGreSql

问题描述

我正在执行以下操作以在 Centos 上安装 PyGreSql:

sudo pip3 install pygresql

但我收到以下错误:

Collecting PyGreSQL
  Using cached https://files.pythonhosted.org/packages/4a/65/03b1cd9b6daaa4e32ee72dd5fb1a01fbb7cd0dfe5439e34af6caa6ec60dc/PyGreSQL-5.0.6.tar.gz
Building wheels for collected packages: PyGreSQL
  Running setup.py bdist_wheel for PyGreSQL
  Complete output from command /usr/local/bin/python3.5 -c "import setuptools;__file__='/tmp/pip-build-scnuzepv/PyGreSQL/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmp0zf45j54pip-wheel-:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
  copying pg.py -> build/lib.linux-x86_64-3.5
  copying pgdb.py -> build/lib.linux-x86_64-3.5
  running build_ext
  building '_pg' extension
  creating build/temp.linux-x86_64-3.5
  gcc -pthread -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPYGRESQL_VERSION=5.0.6 -DDIRECT_ACCESS -DLARGE_OBJECTS -DDEFAULT_VARS -DESCAPING_FUNCS -I/usr/local/include/python3.5m -I/usr/include -I/usr/local/include/python3.5m -c pgmodule.c -o build/temp.linux-x86_64-3.5/pgmodule.o -O2 -funsigned-char -Wall -Werror
  cc1: warnings being treated as errors
  pgmodule.c: In function ‘get_type’:
  pgmodule.c:261: error: will never be executed
  pgmodule.c: In function ‘connGetCastHook’:
  pgmodule.c:3261: error: will never be executed
  pgmodule.c: In function ‘connGetNoticeReceiver’:
  pgmodule.c:3307: error: will never be executed
  pgmodule.c: In function ‘pgGetJsondecode’:
  pgmodule.c:5428: error: will never be executed
  pgmodule.c: In function ‘connInsertTable’:
  pgmodule.c:2618: error: will never be executed
  pgmodule.c:2593: error: will never be executed
  pgmodule.c: In function ‘connQuery’:
  pgmodule.c:2242: error: will never be executed
  pgmodule.c: In function ‘get_col_types’:
  pgmodule.c:371: error: will never be executed
  pgmodule.c: In function ‘cast_sized_simple’:
  pgmodule.c:497: error: will never be executed
  pgmodule.c:476: error: will never be executed
  pgmodule.c:484: error: will never be executed
  pgmodule.c: In function ‘cast_unsized_simple’:
  pgmodule.c:576: error: will never be executed
  pgmodule.c: In function ‘cast_array’:
  pgmodule.c:649: error: will never be executed
  pgmodule.c:3525: error: will never be executed
  pgmodule.c:3492: error: will never be executed
  pgmodule.c: In function ‘sourcePutData’:
  pgmodule.c:4007: error: will never be executed
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for PyGreSQL

谁能告诉我如何解决这个问题?我在互联网上搜索了很多,但没有找到适合我的解决方案。

标签: pythonpython-3.xpippygresql

解决方案


以下是我在 CentOS 7 上安装 Python 3.6、Pip 和 PyGreSQL 5.0.6 的方法:

yum install epel-release 
yum install python36 python36-devel postgresql-libs postgresql-devel
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python36 get-pip.py
pip3 install pygresql

这些命令运行顺利,对我来说没有任何错误。

在任何情况下,在编译 PyGreSQL 之前,您都必须安装 Postgres 和 Python 的开发包。


推荐阅读