Skip to content

bug: postgres dependency fail to install properly #11793

@contang0

Description

@contang0

What happened?

After installing postgres backend I get the below error when trying to use it. I was only able to resolve this issue by installing the binary dependency manually with pip install "psycopg[binary,pq]".

The issue may have been around since 10.7.0. I see that binary dependency of psycopg was removed in 038c339.

What version of ibis are you using?

11.0.0

What backend(s) are you using, if any?

postgres

Relevant log output

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File c:\Mambaforge\envs\test_env\Lib\site-packages\ibis\__init__.py:82, in load_backend(name)
     81 try:
---> 82     module = entry_point.load()
     83 except ImportError as exc:

File c:\Mambaforge\envs\test_env\Lib\importlib\metadata\__init__.py:205, in EntryPoint.load(self)
    204 match = self.pattern.match(self.value)
--> 205 module = import_module(match.group('module'))
    206 attrs = filter(None, (match.group('attr') or '').split('.'))

File c:\Mambaforge\envs\test_env\Lib\importlib\__init__.py:90, in import_module(name, package)
     89         level += 1
---> 90 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1381, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1354, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1325, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:929, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:994, in exec_module(self, module)

File <frozen importlib._bootstrap>:488, in _call_with_frames_removed(f, *args, **kwds)

File c:\Mambaforge\envs\test_env\Lib\site-packages\ibis\backends\postgres\__init__.py:11
      9 from urllib.parse import unquote_plus
---> 11 import psycopg
     12 import sqlglot as sg

File c:\Mambaforge\envs\test_env\Lib\site-packages\psycopg\__init__.py:9
      7 import logging
----> 9 from . import pq  # noqa: F401 import early to stabilize side effects
     10 from . import dbapi20, postgres, types

File c:\Mambaforge\envs\test_env\Lib\site-packages\psycopg\pq\__init__.py:116
    108         raise ImportError(
    109             f"""\
    110 no pq wrapper available.
    111 Attempts made:
    112 {sattempts}"""
    113         )
--> 116 import_from_libpq()
    118 __all__ = (
    119     "ConnStatus",
    120     "PipelineStatus",
   (...)    135     "version_pretty",
    136 )

File c:\Mambaforge\envs\test_env\Lib\site-packages\psycopg\pq\__init__.py:108, in import_from_libpq()
    107         sattempts = "\n".join(f"- {attempt}" for attempt in attempts)
--> 108         raise ImportError(
    109             f"""\
    110 no pq wrapper available.
    111 Attempts made:
    112 {sattempts}"""
    113         )

ImportError: no pq wrapper available.
Attempts made:
- couldn't import psycopg 'c' implementation: No module named 'psycopg_c'
- couldn't import psycopg 'binary' implementation: No module named 'psycopg_binary'
- couldn't import psycopg 'python' implementation: libpq library not found

The above exception was the direct cause of the following exception:

ImportError                               Traceback (most recent call last)
Cell In[3], line 1
----> 1 conn = ibis.postgres.connect(user=user, password=password, host=host, port=5432, database=database)

File c:\Mambaforge\envs\test_env\Lib\site-packages\ibis\__init__.py:142, in __getattr__(name)
    140     return null()  # noqa: F405
    141 else:
--> 142     return load_backend(name)

File c:\Mambaforge\envs\test_env\Lib\site-packages\ibis\__init__.py:84, in load_backend(name)
     82     module = entry_point.load()
     83 except ImportError as exc:
---> 84     raise ImportError(
     85         f"Failed to import the {name} backend due to missing dependencies.\n\n"
     86         f"You can pip or conda install the {name} backend as follows:\n\n"
     87         f'  python -m pip install -U "ibis-framework[{name}]"  # pip install\n'
     88         f"  conda install -c conda-forge ibis-{name}           # or conda install"
     89     ) from exc
     90 backend = module.Backend()
     91 # The first time a backend is loaded, we register its options, and we set
     92 # it as an attribute of `ibis`, so `__getattr__` is not called again for it

ImportError: Failed to import the postgres backend due to missing dependencies.

You can pip or conda install the postgres backend as follows:

  python -m pip install -U "ibis-framework[postgres]"  # pip install
  conda install -c conda-forge ibis-postgres           # or conda install

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior inside of ibis

    Type

    No type

    Projects

    Status

    backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions