title: How to install PyGreSQL using Virtualenv on Mac OS Sierra
body: <p>I'm configuring a <code>virtualenv</code> to work with a legacy webservices application developed on python using flask microframework and <code>PostgreSQL</code>database, this application use <code>PyGreSQL 5.0.3</code> as a dependency to connect with the database.</p>
  
  <p>I have installed the <code>PostgreSQL 9.6.1</code>, i installed it using:</p>
  
  <p><code>brew install postgresql</code></p>
  
  <p>I have installed and working with Python 2.7</p>
  
  <p>When i run the</p>
  
  <p><code>pip install -r requirements.txt</code></p>
  
  <p>i'm gettin this error message:</p>
  
  <pre><code>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 -&gt; build/lib.macosx-10.12-intel-2.7
  copying pgdb.py -&gt; 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
  
  ----------------------------------------
  </code></pre>
  
  <p>As you can see, this error is derived from compile and build the package, but I have the <code>postgresql</code> 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 <code>cc</code> to <code>gcc</code> and i'm having the same error</p>
  
  <p>Any idea how to solve it, thank you in advance</p>