altairbow / django-db-connection-pool

Database connection pool component library for Django
https://pypi.python.org/pypi/django-db-connection-pool/
MIT License
195 stars 24 forks source link

Install: pg_config executable not found. #36

Closed sshleifer closed 1 year ago

sshleifer commented 2 years ago

I'm using google's Cloud SQL for production DB and hitting connection limits.

When I try

pip install "django-db-connection-pool[postgresql]"

I get the following Error: pg_config executable not found. (see Full Traceback below)

Q1) I don't run/configure postgres locally, is this a blocker? Q2) do I need to add anything to INSTALLED_APPS in settings.py or just DATABASES

Thanks!

Env

Python 3.8.12 +

psycopg2-binary           2.9.3                    pypi_0    pypi
django                    4.0.4                    pypi_0    pypi
django-cors-headers       3.12.0                   pypi_0    pypi
django-cursor-pagination  0.2.0                    pypi_0    pypi
django-environ            0.8.1                    pypi_0    pypi
django-sslserver          0.22                     pypi_0    pypi
djangorestframework       3.13.1                   pypi_0    pypi

Full Traceback

``` WARNING: Discarding https://files.pythonhosted.org/packages/6c/79/6df8af2405e2aa60732c47757453fc7fa4af5c90a1796b3392ef892d3a52/psycopg2-2.9.tar.gz#sha256=b12073fdf2002e828e5921be2c39ff9c6eab361c5c0bd6c529619fc23677accc (from https://pypi.org/simple/psycopg2/) (requires-python:>=3.6). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Using cached psycopg2-2.8.6.tar.gz (383 kB) ERROR: Command errored out with exit status 1: command: /home/sam/.conda/envs/character-20220124-sam/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-i7o40hoo/psycopg2_b4149a9e81ea4377befddde281a9336d/setup.py'"'"'; __file__='"'"'/tmp/pip-install-i7o40hoo/psycopg2_b4149a9e81ea4377befddde281a9336d/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-qsylyfe8 cwd: /tmp/pip-install-i7o40hoo/psycopg2_b4149a9e81ea4377befddde281a9336d/ Complete output (25 lines): running egg_info creating /tmp/pip-pip-egg-info-qsylyfe8/psycopg2.egg-info writing /tmp/pip-pip-egg-info-qsylyfe8/psycopg2.egg-info/PKG-INFO writing dependency_links to /tmp/pip-pip-egg-info-qsylyfe8/psycopg2.egg-info/dependency_links.txt writing top-level names to /tmp/pip-pip-egg-info-qsylyfe8/psycopg2.egg-info/top_level.txt writing manifest file '/tmp/pip-pip-egg-info-qsylyfe8/psycopg2.egg-info/SOURCES.txt' /home/sam/.local/lib/python3.8/site-packages/setuptools/config/setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead. warnings.warn(msg, warning_class) Error: pg_config executable not found. pg_config is required to build psycopg2 from source. Please add the directory containing pg_config to the $PATH or specify the full executable path with the option: python setup.py build_ext --pg-config /path/to/pg_config build ... or with the pg_config option in 'setup.cfg'. If you prefer to avoid building psycopg2 from source, please install the PyPI 'psycopg2-binary' package instead. For further information please check the 'doc/src/install.rst' file (also at ). ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/fd/ae/98cb7a0cbb1d748ee547b058b14604bd0e9bf285a8e0cc5d148f8a8a952e/psycopg2-2.8.6.tar.gz#sha256=fb23f6c71107c37fd667cb4ea363ddeb936b348bbd6449278eb92c189699f543 (from https://pypi.org/simple/psycopg2/) (requires-python:>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Collecting django-db-connection-pool[postgresql] Using cached django-db-connection-pool-1.1.0.tar.gz (11 kB) Using cached django-db-connection-pool-1.0.7.tar.gz (7.0 kB) Using cached django-db-connection-pool-1.0.6.tar.gz (7.1 kB) Using cached django-db-connection-pool-1.0.5.tar.gz (6.4 kB) WARNING: django-db-connection-pool 1.0.5 does not provide the extra 'postgresql' Requirement already satisfied: PyMySQL>=0.9.3 in /home/sam/.local/lib/python3.8/site-packages (from django-db-connection-pool[postgresql]) (1.0.2) Requirement already satisfied: cx-Oracle>=6.4.1 in /home/sam/.local/lib/python3.8/site-packages (from django-db-connection-pool[postgresql]) (8.3.0) Using cached django_db_connection_pool-1.0.2-py3-none-any.whl WARNING: django-db-connection-pool 1.0.2 does not provide the extra 'postgresql' Requirement already satisfied: greenlet!=0.4.17 in /home/sam/.local/lib/python3.8/site-packages (from SQLAlchemy>=1.4.24->django-db-connection-pool[postgresql]) (1.1.2) Requirement already satisfied: asgiref<4,>=3.5.2 in /home/sam/.local/lib/python3.8/site-packages (from Django->django-db-connection-pool[postgresql]) (3.5.2) Requirement already satisfied: sqlparse>=0.2.2 in /home/sam/.local/lib/python3.8/site-packages (from Django->django-db-connection-pool[postgresql]) (0.4.2) Requirement already satisfied: backports.zoneinfo in /home/sam/.local/lib/python3.8/site-packages (from Django->django-db-connection-pool[postgresql]) (0.2.1) WARNING: Ignoring invalid distribution -rpcio (/home/sam/.local/lib/python3.8/site-packages) Installing collected packages: django-db-connection-pool ^CERROR: Operation cancelled by user WARNING: Ignoring invalid distribution -rpcio (/home/sam/.local/lib/python3.8/site-packages) WARNING: Ignoring invalid distribution -rpcio (/home/sam/.local/lib/python3.8/site-packages) WARNING: Ignoring invalid distribution -rpcio (/home/sam/.local/lib/python3.8/site-packages) ```
**Describe the bug**
A clear and concise description of what the bug is.

**Environment**
- Python Version: 
- Django Version: 

**Traceback**
Post traceback here.
altairbow commented 2 years ago

Answer1) Don't use psycopg2-binary: psycopg-vs-psycopg-binary, use psycopg2 instead. The error Error: pg_config executable not found. is caused by something(which is postgresql-devel) missing, command pip install django-db-connection-pool[postgresql] will install psycopg2, and psycopg2 requires postgresql-devel, Before installing psycopg2, you should make sure that postgresql-devel is already installed, HOWTO.

Answer2) Neither django-db-connection-pool nor psycopg2 need be added to INSTALLED_APPS.