如何在Mac OS Sierra上使用Virtualenv安装PyGreSQL [英] How to install PyGreSQL using Virtualenv on Mac OS Sierra

查看:118
本文介绍了如何在Mac OS Sierra上使用Virtualenv安装PyGreSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在配置virtualenv以与使用Flask Microframework和PostgreSQL数据库在python上开发的旧版Webservices应用程序一起使用,此应用程序使用PyGreSQL 5.0.3作为与数据库连接的依赖项.

I'm configuring a virtualenv to work with a legacy webservices application developed on python using flask microframework and PostgreSQLdatabase, this application use PyGreSQL 5.0.3 as a dependency to connect with the database.

我已经安装了PostgreSQL 9.6.1,我使用以下方式安装了它:

I have installed the PostgreSQL 9.6.1, i installed it using:

brew install postgresql

我已经安装并使用Python 2.7

I have installed and working with Python 2.7

我运行时

pip install -r requirements.txt

我收到此错误消息:

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库,在其他情况下,我将其视为常见问题.另一方面,我已经安装了Mac的命令行工具,将编译器从cc更改为gcc,并且出现相同的错误

As you can see, this error is derived from compile and build the package, but I have the postgresql library installed, which I see as the common problem in other cases. On the other hand I have installed the command line tools of mac, i changed my compiler from cc to gcc and i'm having the same error

任何想法如何解决,请先谢谢您

Any idea how to solve it, thank you in advance

推荐答案

我通常无法安装此软件包的任何版本.程序包可能有问题.

I wasn't able to install any version of this package normally. It's probably a problem with the package.

解决方法:如果您关闭警告错误提示,则应该可以正常编译.

Workaround: If you turn off warn-as-error, it should compile fine.

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

这篇关于如何在Mac OS Sierra上使用Virtualenv安装PyGreSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆