Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psycopg2 dependency doesn't support all platforms, replace with psycopg2-binary #340

Open
HumzahJavid opened this issue Jun 14, 2024 · 1 comment

Comments

@HumzahJavid
Copy link
Collaborator

HumzahJavid commented Jun 14, 2024

Description of the issue

The install log attached at the bottom of this issue was carried out on a WSL2 instance running ubuntu 22.02 on a windows 10 machine (whilst working on the admin-portal integrations with FIA-API)
The "psycopg2" package threw the following error. This was resolved by replacing it with a non pinned version of "psycopg2-binary"

Recommendation to replace psycopg2 with psycopg2-binary in the pyproject.toml file see stack overflow solution. See #340 (comment)

/home/FIA-API$ pip install .

Processing /home/FIA-API

  Installing build dependencies ... done

  Getting requirements to build wheel ... done

    Preparing wheel metadata ... done

Collecting fastapi[all]==0.110.2

  Downloading fastapi-0.110.2-py3-none-any.whl (91 kB)

     |████████████████████████████████| 91 kB 3.8 MB/s

Collecting psycopg2==2.9.9

  Downloading psycopg2-2.9.9.tar.gz (384 kB)

     |████████████████████████████████| 384 kB 10.6 MB/s

    ERROR: Command errored out with exit status 1:

     command: /home/FIA-API/.venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nmtj8xt4/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-nmtj8xt4/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-nmtj8xt4/psycopg2/pip-egg-info

         cwd: /tmp/pip-install-nmtj8xt4/psycopg2/

    Complete output (23 lines):

    running egg_info

    creating /tmp/pip-install-nmtj8xt4/psycopg2/pip-egg-info/psycopg2.egg-info

    writing /tmp/pip-install-nmtj8xt4/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO

    writing dependency_links to /tmp/pip-install-nmtj8xt4/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt

    writing top-level names to /tmp/pip-install-nmtj8xt4/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt

    writing manifest file '/tmp/pip-install-nmtj8xt4/psycopg2/pip-egg-info/psycopg2.egg-info/SOURCES.txt'
 
    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

    <[https://www.psycopg.org/docs/install.html>).](https://www.psycopg.org/docs/install.html%3E).)
 
    ----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
@HumzahJavid HumzahJavid changed the title psycopg2 dependancy doesn't support all platforms, replace with psycopg2-binary psycopg2 dependency doesn't support all platforms, replace with psycopg2-binary Jun 14, 2024
@keiranjprice101
Copy link
Collaborator

keiranjprice101 commented Jun 25, 2024

From https://www.psycopg.org/docs/install.html#psycopg-vs-psycopg-binary the binary is only reccomended for development. A better solution could be to make a note of the binary version in the docs for development purposes only.

Warning

The psycopg2 wheel package comes packaged, among the others, with its own libssl binary. This may create conflicts with other extension modules binding with libssl as well, for instance with the Python ssl module: in some cases, under concurrency, the interaction between the two libraries may result in a segfault. In case of doubts you are advised to use a package built from source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants