spreaker / prometheus-pgbouncer-exporter

Prometheus exporter for PgBouncer
MIT License
104 stars 38 forks source link

psycopg2 2.8.5 is creating issue in amazon linux #27

Closed ppapishe closed 3 weeks ago

ppapishe commented 3 years ago

We are facing the below issue when we are trying to install the latest version of the exporter that is 2.1.1. Installation is failing with the below error. This is the error when the dependency psycopg2 2.8.5 is getting installed. I tried installing psycopg2 2.7 and it worked fine. Please let me know if there is and workaround other than installing the previous version of the exporter

Processing /root/.cache/pip/wheels/69/08/e9/95c5df2c622165343601e6367f82e19de630629f6e6f2d107a/prometheus_pgbouncer_exporter-2.1.1-py3-none-any.whl
Processing /root/.cache/pip/wheels/99/ad/da/22b0dbe95e769350f2641f2f18c25d3ba3a0ce21dd1f655cf1/python_json_logger-0.1.11-py2.py3-none-any.whl
Collecting prometheus-client==0.8.0
  Using cached prometheus_client-0.8.0-py2.py3-none-any.whl (53 kB)
Collecting psycopg2==2.8.5
  Using cached psycopg2-2.8.5.tar.gz (380 kB)
Requirement already satisfied: PyYAML==5.3.1 in /usr/local/lib64/python3.6/site-packages (from prometheus-pgbouncer-exporter) (5.3.1)
Building wheels for collected packages: psycopg2
  Building wheel for psycopg2 (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nx3s1r9z/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-nx3s1r9z/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-9_z2bchq
       cwd: /tmp/pip-install-nx3s1r9z/psycopg2/
  Complete output (42 lines):
  /usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'project_urls'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.6
  creating build/lib.linux-x86_64-3.6/psycopg2
  copying lib/_json.py -> build/lib.linux-x86_64-3.6/psycopg2
  copying lib/__init__.py -> build/lib.linux-x86_64-3.6/psycopg2
  copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.6/psycopg2
  copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.6/psycopg2
  copying lib/errorcodes.py -> build/lib.linux-x86_64-3.6/psycopg2
  copying lib/compat.py -> build/lib.linux-x86_64-3.6/psycopg2
  copying lib/_range.py -> build/lib.linux-x86_64-3.6/psycopg2
  copying lib/extensions.py -> build/lib.linux-x86_64-3.6/psycopg2
  copying lib/extras.py -> build/lib.linux-x86_64-3.6/psycopg2
  copying lib/pool.py -> build/lib.linux-x86_64-3.6/psycopg2
  copying lib/tz.py -> build/lib.linux-x86_64-3.6/psycopg2
  copying lib/errors.py -> build/lib.linux-x86_64-3.6/psycopg2
  copying lib/sql.py -> build/lib.linux-x86_64-3.6/psycopg2
  running build_ext
  building 'psycopg2._psycopg' extension
  creating build/temp.linux-x86_64-3.6
  creating build/temp.linux-x86_64-3.6/psycopg
  gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=90611 -DHAVE_LO64=1 -I/usr/include/python3.6m -I. -I/usr/include/pgsql96 -I/usr/include/pgsql96/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.6/psycopg/psycopgmodule.o -Wdeclaration-after-statement
  In file included from psycopg/psycopgmodule.c:28:0:
  ./psycopg/psycopg.h:35:20: fatal error: Python.h: No such file or directory
   #include <Python.h>
                      ^
  compilation terminated.

  It appears you are missing some prerequisite to build the package from source.

  You may install a binary package by installing 'psycopg2-binary' from PyPI.
  If you want to install psycopg2 from source, please install the packages
  required for the build and try again.

  For further information please check the 'doc/src/install.rst' file (also at
  <https://www.psycopg.org/docs/install.html>).

  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for psycopg2
  Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: python-json-logger, prometheus-client, psycopg2, prometheus-pgbouncer-exporter
    Running setup.py install for psycopg2 ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nx3s1r9z/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-nx3s1r9z/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-v7t4b391/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6/psycopg2
         cwd: /tmp/pip-install-nx3s1r9z/psycopg2/
    Complete output (42 lines):
    /usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'project_urls'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/psycopg2
    copying lib/_json.py -> build/lib.linux-x86_64-3.6/psycopg2
    copying lib/__init__.py -> build/lib.linux-x86_64-3.6/psycopg2
    copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.6/psycopg2
    copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.6/psycopg2
    copying lib/errorcodes.py -> build/lib.linux-x86_64-3.6/psycopg2
    copying lib/compat.py -> build/lib.linux-x86_64-3.6/psycopg2
    copying lib/_range.py -> build/lib.linux-x86_64-3.6/psycopg2
    copying lib/extensions.py -> build/lib.linux-x86_64-3.6/psycopg2
    copying lib/extras.py -> build/lib.linux-x86_64-3.6/psycopg2
    copying lib/pool.py -> build/lib.linux-x86_64-3.6/psycopg2
    copying lib/tz.py -> build/lib.linux-x86_64-3.6/psycopg2
    copying lib/errors.py -> build/lib.linux-x86_64-3.6/psycopg2
    copying lib/sql.py -> build/lib.linux-x86_64-3.6/psycopg2
    running build_ext
    building 'psycopg2._psycopg' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/psycopg
    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=90611 -DHAVE_LO64=1 -I/usr/include/python3.6m -I. -I/usr/include/pgsql96 -I/usr/include/pgsql96/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.6/psycopg/psycopgmodule.o -Wdeclaration-after-statement
    In file included from psycopg/psycopgmodule.c:28:0:
    ./psycopg/psycopg.h:35:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.

    It appears you are missing some prerequisite to build the package from source.

    You may install a binary package by installing 'psycopg2-binary' from PyPI.
    If you want to install psycopg2 from source, please install the packages
    required for the build and try again.

    For further information please check the 'doc/src/install.rst' file (also at
    <https://www.psycopg.org/docs/install.html>).

    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nx3s1r9z/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-nx3s1r9z/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-v7t4b391/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6/psycopg2 Check the logs for full command output.
esanchezm commented 3 years ago

Well, the quickest fix is to stay in 2.1.0 as the only change in 2.1.1 were the dependencies. However, I can see that you're missing the python devel library and it can't install the requirements. Try to install python-devel package

yum install python-devel

Which python version are you using?

ppapishe commented 3 years ago

yes, I am using install prometheus-pgbouncer-exporter==2.1.0 as a workaround.
for installing the exporter, I am using pip3 python 3.6

I will try installing python-devel and try. Thanks for your reply.