如何在Mac OS Sierra上使用Virtualenv安装PyGreSQL

时间:2017-02-11 07:06:36

标签: python postgresql pip virtualenv pygresql

我正在使用flask microframework和PostgreSQL数据库配置PyGreSQL 5.0.3以使用在python上开发的遗留Web服务应用程序,此应用程序使用PostgreSQL 9.6.1作为依赖关系来连接数据库

我安装了brew install postgresql,我使用以下方法安装了它:

pip install -r requirements.txt

我已安装并使用Python 2.7

当我运行

Running setup.py install for PyGreSQL ... error Complete output from command /Users/user/Development/Projects/flask/ws/myenv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/t1/x7lrbmyd3lq0k8ngknwg1zx00000gn/T/pip-build-KjQgiU/PyGreSQL/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/t1/x7lrbmyd3lq0k8ngknwg1zx00000gn/T/pip-3lBp1N-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/user/Development/Projects/flask/ws/myenv/include/site/python2.7/PyGreSQL: running install running build running build_py creating build creating build/lib.macosx-10.12-intel-2.7 copying pg.py -> build/lib.macosx-10.12-intel-2.7 copying pgdb.py -> build/lib.macosx-10.12-intel-2.7 running build_ext building '_pg' extension creating build/temp.macosx-10.12-intel-2.7 cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DPYGRESQL_VERSION=5.0.3 -DDIRECT_ACCESS -DLARGE_OBJECTS -DDEFAULT_VARS -DESCAPING_FUNCS -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/Cellar/postgresql/9.6.1/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pgmodule.c -o build/temp.macosx-10.12-intel-2.7/pgmodule.o -O2 -funsigned-char -Wall -Werror pgmodule.c:4143:9: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32] num = PyInt_AsLong(param); ~ ^~~~~~~~~~~~~~~~~~~ pgmodule.c:4448:12: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32] pgport = PyInt_AsLong(pg_default_port); ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 errors generated. error: command 'cc' failed with exit status 1 ----------------------------------------

我收到此错误消息:

postgresql

正如您所看到的,此错误源自编译和构建程序包,但我安装了cc库,我认为这是其他情况下的常见问题。另一方面,我安装了mac的命令行工具,我将编译器从gcc更改为<html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" href="style.css"/> <script src="jquery.js"></script> <script src="script.js"></script> </head> <body> <div class="menu"> <ul> <li class="page2" id="page2">PAGE TOW</li> <li class="page3" id="page3">PAGE THREE</li> </ul> </div> <div class="load"></div> </body> </html> ,我遇到了同样的错误

任何想法如何解决,提前谢谢

1 个答案:

答案 0 :(得分:5)

我无法正常安装此软件包的任何版本。这可能是包的问题。

解决方法:如果关闭warn-as-error,它应该编译正常。

export CFLAGS="-Wno-error"
pip install PyGreSQL